2014-07-08 6 views
0

Magento에서 내 피드 순서를 변경 한 사용자 지정 관찰자를 만들었습니다. config.xml에서이 부분을 활성화했습니다.Magento - 피드 정렬 기준 날짜 속성

<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를 추가해도 아무런 변화가 없습니다. 누군가 나를 도와 줄 수 있습니까?

답변

0
  1. 해당 속성 news_to_date는 검색 및 정렬에 필요한 것으로 설정되어 있습니까?

  2. Solr 또는 전체 텍스트 검색을 사용하고 있습니까?

  3. solr이 제품 용으로 채워진 필드에 대해 solr tunnel 및 query solr을 사용하는 경우.

  4. Solr에서 저장소가 문제를 생성 할 때이 특정 특성이 잘못된 값을 추출한다는 것을 발견했습니다.

+0

1. 예. 이렇게 설정됩니다. 2,3 나는 이걸 어떻게 확인할 수 있습니까? – Alex

+0

설정 : 카탈로그 검색> 검색 엔진을 확인해야합니다. – oscprofessionals

+0

포인트 3에 대해 Google에 Solr을 쿼리하는 방법이 필요합니다. – oscprofessionals