有没有人知道从Magento产品系列中读取排序顺序数组的聪明方法?对象中有受保护的属性_orders
。我可以通过
$collection->getSelect()->getPart('order')
然后我必须进行字符串解析。 我希望有一种公共方法可以从产品集合中获取排序顺序信息吗?
答案 0 :(得分:1)
您可以使用Reflection
:
$property = new ReflectionProperty(get_class($collection), '_orders');
$property->setAccessible(true);
$orders = $property->getValue($collection);
但是你不会避免一些字符串解析,因为订单值存储在字符串中($field.' '.Varien_Data_Collection::SORT_ORDER_(ASC|DESC)
)
答案 1 :(得分:0)
对于带工具栏的产品集合,您可以向工具栏询问当前的排序顺序:
Mage::getBlockSingleton('catalog/product_list_toolbar')->getCurrentOrder()