Follow by Email

Wednesday, May 16, 2012

Autocomplete ajax search in magento

Hi all,
I had a problem with Ajax search auto suggest in magento. The top search in magento i want to make it as a ajax search. so i did some change in
app\code\core\Mage\CatalogSearch\Block\Autocomplete.php
under the "getSuggestData" function
just comment the    foreach ($collection as $item) {     start to end
and past the this code

$resource = Mage::getSingleton('core/resource');
            $conn = $resource->getConnection('core_read');
            $results = $conn->query("SELECT pv.value,pv.entity_id FROM catalog_product_entity_varchar pv,catalog_product_entity pe where pv.attribute_id=65 and pv.value like '%".$query."%' and pv.entity_id=pe.entity_id and pe.type_id='configurable'")->fetchAll();       
            //this custom query add by sourav for autocomplet product search
           
            $counter = 0;
            $data = array();
            foreach ($results as $item) {
                $_data = array(
                    'title' => $item['value'],
                    'row_class' => (++$counter)%2?'odd':'even',
                    'num_of_results' => ''
                );
       
                if ($item['value'] == $query) {
                    array_unshift($data, $_data);
                }
                else {
                    $data[] = $_data;
                }
               
            }

1 comment:

  1. Hi
    i am new in magento can you please help me in this i want Short Descreption, Addtocart Button in Search Autocomplete. please help

    ReplyDelete