我需要找到一种方法来添加另一个排序顺序,以便我可以随机排序或我需要覆盖核心搜索系统,以使我能够实现相同。 (或两者的某种组合?)覆盖mangento搜索系统,以允许随机顺序
我知道magento搜索文件在app/code/core/Mage/CatalogSearch /中,但我不确定哪些文件需要查看更改。
我需要找到一种方法来添加另一个排序顺序,以便我可以随机排序或我需要覆盖核心搜索系统,以使我能够实现相同。 (或两者的某种组合?)覆盖mangento搜索系统,以允许随机顺序
我知道magento搜索文件在app/code/core/Mage/CatalogSearch /中,但我不确定哪些文件需要查看更改。
文件你寻找是app/code/core/Mage/CatalogSearch/Model/Layer.php
。该班的名字是Mage_Catalog_Model_Layer
。在里面你可以看到功能prepareProductCollection($collection)
。
我建议你改写这个模型(参见this或this)并覆盖上述功能并添加/实现你的排序逻辑。重写此功能的示例为
class XXX_XXX_Model_CatalogSearch_Layer extends Mage_CatalogSearch_Model_Layer
{
public function prepareProductCollection($collection)
{
parent::prepareProductCollection($collection);
$collection->addAttributeToSelect('some_attribute');
$collection->setOrder('some_attribute', 'asc');
return $this;
}
}
转到文件位置的社区\程序\代码\核心\法师\ CatalogSearch \块\ Result.php和发现功能公共职能setListOrders(),在这里你可以改变你的客户订单