I've a created a custom observer within Magento for changing the order of my feed. In the config.xml I enabled this part.
<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>
I've changed the Example.php to this.
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
}
The 'new_to_date' is a attribute with a date value. Now what I need is that the feed will be sorted by this date descending. But nothing happens when I add the addAttributeToSort. Can someone help me out here?
Is that attribute news_to_date set as required for search and sort.
Is your search using Solr or full text search.
if solr use solr tunnel and query solr for fields that had been populated for products.
We have found that this specific attribute when stores in Solr creates issues as is extracts wrong values.