2014-01-13 66 views
2

如何通過名稱或其他屬性對相關產品集合進行排序?
我已經試過類似:
Magento添加排序getRelatedLinkCollection()

foreach ($_product->getRelatedLinkCollection()->addAttributeToSort('name', 'ASC') as $link) {...} 

但它沒有工作。

+0

請不要回答? – Gulp

回答

0

方法getRelatedLinkCollection不會返回預期的產品集合,而是不支持addAddtributeToSelectaddAttributeToSort等方法的Mage_Catalog_Model_Resource_Product_Link_Collection

看一看這個答案:https://stackoverflow.com/a/26184265/4762900。這幾乎是你想要實現的。