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 Answers 2

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...!!!

8
  • Not working it is the sales rule & I want to add a condition in loadAttributeOptions()
    – Arjun
    Commented Aug 29, 2019 at 12:18
  • @Arjun : so what challange you are facing to add a condition in loadAttributeOptions() function ? Commented Aug 29, 2019 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
    Commented Aug 29, 2019 at 12:27
  • @Arjun : can you tell me on which page this function are using? Commented Aug 29, 2019 at 12:38
  • Admin > Marketing > cart price rule > inside conditions
    – Arjun
    Commented Aug 29, 2019 at 12:39
0

Your must use like below

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

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.