我创建了一个模块来在类别页面的“排序依据”下拉框中添加一个新选项。新选项应显示在每个类别页面中,与已经存在的“位置”选项相同。我想添加“人气”作为选项。我的模型类正在执行,它正在将选项添加到选项数组。但是该块不起作用。请问我需要你的帮助来找到我的代码中的问题吗?
这是块类
<?php
class Tal_Popularity_Block_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
{
public function setCollection($collection)
{
$this->_collection = $collection;
$this->_collection->setCurPage($this->getCurrentPage());
// we need to set pagination only if passed value integer and more that 0
$limit = (int)$this->getLimit();
if ($limit) {
$this->_collection->setPageSize($limit);
}
if($this->getCurrentOrder() == 'popularity'){
$this->_collection->sortByReview($this->getCurrentDirection());
}
else if ($this->getCurrentOrder()) {
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}
return $this;
}
}
以下是我的 config.xml
<?xml version="1.0" ?>
<config>
<modules>
<Tal_Popularity>
<version>0.1.0</version>
</Tal_Popularity>
</modules>
<frontend>
<routers>
<popularity>
<use>standard</use>
<args>
<module>Tal_Popularity</module>
<frontName>popularity</frontName>
</args>
</popularity>
</routers>
</frontend>
<global>
<models>
<catalog>
<rewrite>
<config>Tal_Popularity_Model_Config</config>
</rewrite>
</catalog>
</models>
<blocks>
<catalog>
<rewrite>
<catalog>Tal_Popularity_Block</catalog>
</rewrite>
</catalog>
</blocks>
<resources>
<popularity_setup>
<setup>
<module>Tal_Popularity</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</popularity_setup>
<popularity_write>
<connection>
<use>core_write</use>
</connection>
</popularity_write>
<popularity_read>
<connection>
<use>core_read</use>
</connection>
</popularity_read>
</resources>
</global>
</config>