doudi4621 2014-07-08 07:29 采纳率: 0%
浏览 18
已采纳

Magento - Feed按日期属性排序

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?

  • 写回答

1条回答 默认 最新

  • dongpochi9741 2014-07-08 19:14
    关注
    1. Is that attribute news_to_date set as required for search and sort.

    2. Is your search using Solr or full text search.

    3. if solr use solr tunnel and query solr for fields that had been populated for products.

    4. We have found that this specific attribute when stores in Solr creates issues as is extracts wrong values.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路