Basically I want to make magento default store credit(Magento_CustomerBalance) to be enable/disable at website level scope(by default its global level)

I have overirded & made changes in certain files which then, it works well on store front for website level, but on magneto admin it does not work as expected

ie. on admin customer edit it dosnt show me store credit tab, even if the customer is from website on which store credit is enabled, Also on admin order pages, store credit is not getting included in totals

So as per my findings, in \vendor\magento\module-customer-balance\etc\di.xml there is a part of code

<type name="Magento\Framework\Module\Manager">
        <argument name="outputConfigPaths" xsi:type="array">
            <item name="Magento_CustomerBalance" xsi:type="const">Magento\CustomerBalance\Helper\Data::XML_PATH_ENABLED</item>

if I remove it entirely(from magento core module's di.xml) & run di:compile the autogenerated file, \generated\metadata\global.php will be not having below code

'Magento_CustomerBalance' => 'customer/magento_customerbalance/is_enabled',

Then my customization is working well, So inshort either I want to override di.xml & would like to pass certain argument which then exclude it as global constant OR even if thats not possible When auto generation happens I would like to skip to be added(excluded)

'Magento_CustomerBalance' => 'customer/magento_customerbalance/is_enabled',

in autogenerated global.php But somehow not able to find, how to achieve this

1 Answer 1


You have totally wrong approach. You should just create a plugin on enable method and limit it in your scope. So lets say that there is a method isEnabled then you should create afterIsEnable and limit it for selected websites.

  • In my overrided code, I have added websiteId in isEnabled() & where ever its getting called in core files I have also overrided all those files to pass websiteId thats why its working well on store front, but as it's constant is getting added in generated/metadata/global.php which is declared in module's di.xml thats why its not working on admin, If I remove from di & run compile it works fine on admin also OR if I let it remain in di.xml & after running di:compile If I manually remove it from global.php then also it works well on admin, but I am not getting how to override that di.xml Nov 19, 2023 at 11:42
  • My approach might be wrong , but the thing which you are trying to say, I guess I have already done Nov 19, 2023 at 11:43

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.