2

I am using this article to create a custom condition in the cart rule where I want to add the stock qty including other product attributes in the rule condition.

For example if product_attribute1 = Adidas and product_qty >= 100 apply the rule on that product.

I can add conditions successfully, but when I try to validate the rule with product qty. I am facing some issues.

When I debug the code and find that there is the wrong class attached in $model

echo get_class($model);

result: Magento\Quote\Model\Quote\Address

I have changed Customer (Magently\CustomerRule\Model\Rule\Condition\Customer) class to Product (Magently\CustomerRule\Model\Rule\Condition\Product) class, but still it showing Magento\Quote\Model\Quote\Address in validate function.

I need the Magento\Quote\Model\Quote\Item class, as I review the core functionality so that I can get the product qty and validate the product qty before applying the rule in the cart.

Please let me know where the address class is defined SO I can change it or is there any other way to do this.

0
0

Follow the Below link is a full Example.

Click Here For Part 1

Click Here For Part 2

Click Here For Part 3

For Sales Rule Replace class in CustomCondition.php at app/code/VendoreName/AddConditionFiled/Model

From

....
\Magento\CatalogRule\Model\Rule\Condition\CombineFactory $condCombineFactory,
\Magento\SalesRule\Model\Rule\Condition\Product\CombineFactory $condProdCombineF,
....

To

....
\Magento\SalesRule\Model\Rule\Condition\CombineFactory $condCombineFactory,
\Magento\SalesRule\Model\Rule\Condition\Product\CombineFactory $condProdCombineF,
....

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.