0
我期待有正常的快速搜索,並增加一個功能:來自給定類別的結果首先出現。Magento快速搜索 - 顯示給定類別的結果第一個
到目前爲止,我已修改protected function _getProductCollection()
在Mage_CatalogSearch_Block_Result
這個工作,但它忽略了我想要在兩組結果中應用的自定義搜索結果(例如通過價格或名稱)。
我額外的代碼是:
$initial = $this->_productCollection->getAllIds();
$this->_productCollection->addCategoryFilter(Mage::getModel('catalog/category')->load(3));
$newids = $this->_productCollection->getAllIds();//$this->_productCollection->getAllIds();
$merged_ids = array_merge($newids, $initial);
$merged_ids = array_unique($merged_ids);
$this->_productCollection->addCategoryFilter(Mage::getModel('catalog/category')->load(2));
$this->_productCollection->getSelect()->order("find_in_set(e.entity_id,'".implode(',',$merged_ids)."')");
凡貓2根類別。
那麼,集合在哪裏被排序呢?如果我在這裏提出這個應該做我認爲的訣竅(?)。
另一種可能是訪問'getCurrentOrder ()'和'getCurrentDirection()'從'Toolbar.php'中。我該怎麼做? –