0

You can addAttributeToFilter for product collection;

$this->_productCollectionFactory->create()->addAttributeToFilter('att_x', ['eq', $att_x_value]);

How can we do this with bestseller collection (\Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory)

And the attribute value is entity id of my custom table. I couldn't figure out how to join which tables.

Thanks in advance.

1 Answer 1

0

Method addAttributeToFilter doesn't exist in class \Magento\Sales\Model\ResourceModel\Report\Bestsellers\Collection but we can use method addFieldToFilter

Can you retry with method addFieldToFilter?

E.g.

$this->_bestSellerCollectionFactory->create()->addFieldToFilter('att_x', ['eq' => $att_x_value]);

Please note that field att_x needs to exist in the collection data, otherwise, we need to join it before filtering.

1
  • Hi. att_x doesn't exist in bestseller collection. att_x is a custom attribute added to product. I have to make a join to combine bestseller table, my custom table and product attributes table. I couldn't find though which tables to use for product attributes table.
    – iskorum
    Commented Apr 22, 2020 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.