0

I am not able to override this file vendor/magento/module-sales-rule/Model/Rule/Condition/Address.php using preference.

<preference for="Companyname\Subtotalwithdiscount\Model\Rule\Condition\Address" type="Magento\SalesRule\Model\Rule\Condition\Address" />

Can someone guide me on this?

2

Try below code:

{{your name space}}/ {{Module name}}/etc/adminhtml/di.xml

<preference for="Magento\SalesRule\Model\Rule\Condition\Address" type="Companyname\Subtotalwithdiscount\Model\Rule\Condition\Address" />

There is sequencing issue in your code.

Note: Make sure your di.xml file is locate at etc/adminhtml/di.xml.

I hope it will help...!!!

  • Not working it is the sales rule & I want to add a condition in loadAttributeOptions() – Arjun Aug 29 at 12:18
  • @Arjun : so what challange you are facing to add a condition in loadAttributeOptions() function ? – Balwant Singh Aug 29 at 12:24
  • In this file Companyname\Subtotalwithdiscount\Model\Rule\Condition\Address I have added this function loadAttributeOptions(). Here I am doing echo 'aa';exit; . it is not refelcting. It is stll coming from vendor – Arjun Aug 29 at 12:27
  • @Arjun : can you tell me on which page this function are using? – Balwant Singh Aug 29 at 12:38
  • Admin > Marketing > cart price rule > inside conditions – Arjun Aug 29 at 12:39
0

Your must use like below

<preference for="Magento\SalesRule\Model\Rule\Condition\Address" type="Companyname\Subtotalwithdiscount\Model\Rule\Condition\Address" />
  • Not working it is the sales rule & I want to add a condition in loadAttributeOptions() – Arjun Aug 29 at 12:18

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.