I use the Use for Promo Rule Conditions flag. How can I filter only products having this flag set to yes? Is there a table where it is set so that I can use it for filtering?

enter image description here


I found the Solution myself. Just wanna share it with you :)

There is a Table called catalog_eav_attribute which shows us in some row if the product is used for promo rules.

So what I've done is. I injected the Attribute Collection from \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection

and set up my DI in my Model like this:

public function __construct(
    \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection $attributeCollection
    $this->_attributeCollection = $attributeCollection;

and now i can loop over the collection like this:

$collection = $this->_attributeCollection->addFieldToFilter('is_used_for_promo_rules', 1)->load();

foreach ($collection as $test) {
     $id = $test->getId();
     $name = $test->getName();

now the $name will be your Attribute Code and $id the Attribute Id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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