我认为问题是在Mage_Catalog_Block_Product_List块getSortBy魔术方法。而在
protected function _beforeToHtml()
您可能会看到代码
if ($sort = $this->getSortBy()) {
$toolbar->setDefaultOrder($sort);
}
...
$toolbar->setCollection($collection);
然后到工具栏(Mage_Catalog_Block_Product_List_Toolbar)
public function setCollection($collection)
{
...
if ($this->getCurrentOrder()) {
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}
我觉得这是一个问题。您可以尝试重写保护功能_beforeToHtml()在你的块并改变
if ($sort = $this->getSortBy()) {
$toolbar->setDefaultOrder($sort);
}
到
$collection->addAttributeToSort('news_from_date','desc');
或可观察“catalog_block_product_list_collection”和更改排序那里。这些只是建议,但我可以直接在_beforeToHtml()和工具栏中看到问题。