Filter Magento collection but not products, using distinct

前端 未结 2 493
遥遥无期
遥遥无期 2020-12-31 14:09

In my magento store I am trying to retrieve a list of youtube videos from a DB table, some videos are duplicated.

I\'m looking to filter videos by using distinct vid

相关标签:
2条回答
  • 2020-12-31 14:37

    While adding the join make sure blank array is passed in the third parameter.

    $this->getSelect()->joinLeft(
        'sales_order_item',
        'sales_order_item.order_id = main_table.order_id',
        []
    );
    

    After that add the following to apply DISTINCT

    $this->getSelect()->distinct(true);
    
    0 讨论(0)
  • 2020-12-31 14:39

    You can try this:

    $collection->getSelect()->distinct(true);
    

    But this will retrieve distinct values based on id. If you want to retrieve videos using distinct video values, you should group by "value".

    $collection->getSelect()->group('value');
    

    If you want to debug the query executed :

    $collection->getSelect()->__toString();
    

    Hope this helps

    0 讨论(0)
提交回复
热议问题