php - Magento search results in wrong order -


i'm working on magento 1.9.1.0 project , search results aren't being displayed in correct order. i've modified function fetch results in order of position (which works), appears looping through each category first, listing products category in order of position , name , moving on next category - example, if search "a":

anti-slip bath mat, bath safety strips, square shower mat, walking frame, (here order breaks, because it's entered new category) alarm clock, amplified phone.

i'd have liked have returned:

alarm clock, amplified phone, bath safety strips, square shower mat, walking frame, anti-slip bath mat

(anti-slip bath mat last, because position of else 0 product has position of 10).

is there way can amend search display products without ordering them in category order? function i'd written achieve have far is:

public function setlistorders() {     $category = mage::getsingleton('catalog/layer')         ->getcurrentcategory();     /* @var $category mage_catalog_model_category */     $availableorders = $category->getavailablesortbyoptions();     unset($availableorders['position']);     $availableorders = array_merge(array(         'relevance' => $this->__('relevance'),         'name' => $this->__('name'),         'position' => $this->__('position')     ), $availableorders);      $this->getlistblock()         ->setavailableorders($availableorders)         ->setdefaultdirection('asc')         ->setsortby('position');     return $this;  } 

and...

protected function _getproductcollection() {     if (is_null($this->_productcollection)) {         $this->_productcollection = $this->getlistblock()->getloadedproductcollection();     }  return $this->_productcollection->addattributetosort('position')->addattributetosort('name');  } 

edit: i'm trying achieve sort products custom attribute called "pay_in_store", results seem spit out first category of results in correct order , results category don't have option "pay_in_store" checked. jumps next category , same. don't want on per-category basis - need products emptying results.

add below code local.xml or in layout.xml file

<catalogsearch_result_index>  <reference name="search_result_list">     <action method="setdefaultdirection"><param>asc</param></action>     <action method="setsortby"><param>attribute_you_want_to_use</param></action>  </reference> </catalogsearch_result_index> 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -