2

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.

enter image description here

4 Answers 4

2

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 an attribute_model of type Magento\Eav\Model\Entity\Attribute when the system is actually expecting type Magento\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 the eav_attribute and/or eav_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!

Just a note: if you continue to run into this issue, it may be the case that you have some code (maybe custom or a 3rd party module) that is adding/updating an attribute and setting that attribute_model value incorrectly

0

It's a native issue, but you can try these options:

1 - Try disabling third-party extensions (e.g. Mgt_DeveloperToolbar).

2 - Try to refresh or disable the cache before.

3 - As a temporary fix you can do that:

Override the file vendor/magento/module-rule/Model/Condition/Product/AbstractProduct.php override the method Magento\Rule\Model\Condition\Product\AbstractProduct::loadAttributeOptions(), and change the line:

if (!$attribute->isAllowedForRuleCondition() || !$attribute->getDataUsingMethod($this->_isUsedForRuleProperty))

to

if (!$attribute->getDataUsingMethod($this->_isUsedForRuleProperty) ||!$attribute->isAllowedForRuleCondition())
0
0

It could be full page cache error

Flush Magento Cache or redeploy the code by below commands

  1. setup upgrade: php bin/magento se:up
  2. Static content deploy: php bin/magento s:s:d -f
  3. Cache flush: php bin/magento c:f
  4. Re-index: php bin/magento indexer:reindex
0

Its actually an easy fix - Just close any other Magento admin windows in your browser and refresh cache. Then press ctrl + F5 to force refresh your browser session and try again.

In my case, I had one Magento admin window open with Mirakl listings setup, and it wasnt acknowledging the cache refresh that I was doing in a separate window.

Everything was going fine setting up new listings until I added new dropdown options to an existing attribute in a new window, which was used in some product listings in the other window.

Best stick to one window, and don't share logins :D

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.