magento Custom search programmatically

how to magento Custom search programmatically

In this post we will show you how to magento Custom search programmatically, hear for how to magento Custom search programmatically we will give you demo and example for implement.

this is a code a controller intended to expose Magento’s catalog search functionality to API calls. Using filters with the default REST api just doesn’t return the same quality results as the search feature available on a Magento site.

Magento search model is more intricate as they assembled a component to spare questions and comes about for storing and measurements. In this way, you have to set up the question protest, at that point set up the outcome and after that you can join the item accumulation with the query output table. Here is the manner by which to do it in code.

Method 1 :: magento Custom search programmatically

$searchText = 'add you text';
$custom_query = Mage::getModel('catalogsearch/query')->setQueryText($your_search_text)->prepare();
$fulltext_resource = Mage::getResourceModel('catalogsearch/fulltext')->prepareResult(

$catalog_collection = Mage::getResourceModel('catalog/product_collection');
array('search_result' => $catalog_collection->getTable('catalogsearch/result')),
'search_result.product_id=e.entity_id AND search_result.query_id=?',
array('relevance' => 'relevance')

$catalog_collection is a filtered down catalog product collection of which we can then perform any additional operations depending on what we need :



Method 2 :: magento Custom search programmatically

$searchText = 'add you text';
$setsearchQuery = $this->getRequest()->getPost($searchText);

$set_collection = Mage::getModel('catalog/product') ->getCollection();
$set_collection->addAttributeToFilter('name', array(
//array('like' => '%'.$setsearchQuery.'%'),
//spaces on each side
//array('like' => '%'.$setsearchQuery),
// space before and ends with $needle
array('like' => $setsearchQuery.'%')
// starts with needle and space after
echo "<pre>";
echo "</pre>";

Method 3 :: magento Custom search programmatically

$searchText = 'add you text';
$storeId = '1'; // add your store id
$catalog_collection = Mage::getResourceModel("catalog/product_collection")->addAttributeToSelect("*");
$custom_query = Mage::helper("catalogSearch")->getQuery();
$catalog_collection = $custom_query->getSearchCollection();
$catalog_collection->addAttributeToFilter("status", 1);
foreach($catalog_collection as $product_val)
// do something  you want

Hope this code and post will helped you for implement magento Custom search programmatically. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

Leave a Comment

Your email address will not be published. Required fields are marked *

28  +    =  29

We accept paid advance and paid guest Posting on our Site : Contact US