I am getting an issue on Magento 2.2 when trying to create promotion rule. This error occurs sometimes and the error disappears if run Magento upgrade command. But it comes again sometime.
Magento – Invalid method Magento\Eav\Model\Entity\Attribute::isAllowedForRuleCondition
eaventity-managermagento2magento2.2
Best Answer
The Issue:
My team recently ran into this on
v2.3.1
of Magento Community, and it appears that you may have an attribute with anattribute_model
of typeMagento\Eav\Model\Entity\Attribute
when the system is actually expecting typeMagento\Catalog\Model\ResourceModel\Eav\Attribute
For reference, you can check out the line of code where that error is being thrown. For me it's here: https://github.com/magento/magento2/blob/2.3.1/app/code/Magento/SalesRule/Model/Rule/Condition/Product.php#L70-L71
You'll see a comment on the type of what that variable is (expected to be):
/* @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
The Solution:
Well, my solution was to update that
attribute_model
value in theeav_attribute
and/oreav_entity_type
tables directly - you'll see some others have done this in the Magento issue linked to in Rafael's answer. After this, you'll want to make sure you run a reindex and clear cache. Hope that helps!