首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Magento按日期排序

Magento按日期排序
EN

Stack Overflow用户
提问于 2014-07-08 07:29:03
回答 1查看 212关注 0票数 0

我在Magento中创建了一个自定义观察者,用于更改我的提要的顺序。在config.xml中,我启用了这个部分。

代码语言:javascript
运行
复制
<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改成这个了。

代码语言:javascript
运行
复制
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时,什么都不会发生。有人能帮我一下吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-08 19:14:36

  1. 是搜索和排序所需的属性news_to_date集。
  2. 是使用Solr搜索还是全文搜索。
  3. 如果solr使用solr隧道,并查询solr中已填充的产品字段。
  4. 我们已经发现,当Solr中的存储产生问题时,这个特定属性会产生问题,因为提取错误的值。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24626058

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档