How to filter an EAV or a flat collection (product, category, sales, etc.) with the addAttributeToFilter() method?

Context: How to filter a database collection?

1. \Magento\Catalog\Model\ResourceModel\AbstractCollection::addAttributeToFilter()

2. \Magento\Catalog\Model\ResourceModel\Category\Flat\Collection::addAttributeToFilter()

3. \Magento\Catalog\Model\ResourceModel\Product\Collection::addAttributeToFilter()

4. \Magento\Eav\Model\Entity\Collection\AbstractCollection::addAttributeToFilter()

5. \Magento\Sales\Model\ResourceModel\Collection\AbstractCollection::addAttributeToFilter()

Usages

1

2

3

4

5

6

7

8

9

10

11

See also: