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.

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

报告相同问题?

悬赏问题

  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器