我在Magento中创建了一个自定义观察者,用于更改我的提要的顺序。在config.xml中,我启用了这个部分。
<ewfeed_feed_products>
<observers>
<example_ewfeed_products>
<type>singleton</type>
<class>ewfeed/observer_example</class>
<method>feedProducts</method>
</example_ewfeed_products>
</observers>
</ewfeed_feed_products>
我已经把Example.php改成这个了。
static function feedProducts(Varien_Object $observer)
{
$feed = $observer->getFeed();
$productCollection = $observer->getProductCollection();
$transport = $observer->getTransport();
//lets try sorting
$productCollection->addAttributeToSort('news_to_date', 'DESC');
$originalIds = $productCollection->getAllIds();
// any ids set here are products that will be used in the feed. they will be listed in the order of the ids in the array
// so if you change the order it will change the order of the outputted products. you can also filter products here
$transport->setProductIds($originalIds); // set to null to use default
}
“new_to_date”是一个具有日期值的属性。现在,我需要的是,提要将按这个日期排序下降。但是,当我添加addAttributeToSort时,什么都不会发生。有人能帮我一下吗?
发布于 2014-07-08 19:14:36
https://stackoverflow.com/questions/24626058
复制相似问题