【发布时间】:2012-05-18 23:03:13
【问题描述】:
我希望进行正常的快速搜索,并增加一个功能:给定类别的结果排在第一位。
到目前为止,我已经在 Mage_CatalogSearch_Block_Result 中修改了 protected function _getProductCollection() 并且这有效,但它忽略了我想在两组结果中应用的自定义搜索结果(例如按价格或名称)。
我的附加代码是:
$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)."')");
cat 2 是根类别。
那么,排序的集合在哪里?如果我把它移到那里,我认为应该可以解决问题(?)。
【问题讨论】:
-
另一种方法是从
Toolbar.php访问getCurrentOrder()和getCurrentDirection()。我该怎么做?
标签: magento sorting collections magento-1.6