2

I have a core js file that I want to override, but everything I have tried has failed, including essentially copying the method used by another core file being overridden that does work. Here is what I have in my requirejs.config.js so far:

var config = {
    map: {
        "*": {
            'Magento_Checkout/js/view/minicart':'js/view/minicart', //This one is overriden properly
            'Magento_Checkout/js/action/place-order':'js/action/place-order' //This one won't override
        }
    }
};

Here are the paths to both files that won't override:

core file: vendor/magento/module-checkout/view/frontend/web/js/action/place-order.js

override file: app/design/frontend/MyNamespace/mymodule/Magento_Checkout/web/js/action/place-order.js

And for reference, here are the paths to the one that IS being overridden:

core file: vendor/magento/module-checkout/view/frontend/web/js/view/minicart.js

override file:

app/design/frontend/MyNamespace/mymodule/Magento_Checkout/web/js/view/minicart.js

I am using Magento 2.2.6 as well.

I have cleared the cache multiple times and because I am in a dev environment, I don't need to deploy static content, but I tried it anyway, still didn't work. I can't figure out why one would override and the other doesn't.

Any help is appreciated.

  • Try the below answer and let me know for queries :) @EricBrown – Prathap Gunasekaran Mar 29 at 4:24
1

If you're overriding by your theme then you don't need requirejs-config.js because it's fallback methodology so just place the file in your theme. The path should be like this

app/design/frontend/Vendor/theme-name/Magento_Checkout/web/js/view/minicart.js

Hoping this would be your theme MyNamespace/mymodule say it eg : Smarwave/porto

There are two ways to override core js

  1. One by just moving it the theme

  2. Another one by custom module Refer this to override custom js by custom module

since I don't know why it's not done for you because it seems you done everything right.

Just remove the requirejs-config.js from your theme and move your core js to theme like above.

After moving your files to your theme do run the following commands,

rm -rf pub/static/frontend
php bin/magento setup:upgrade
php bin/magento s:s:d -f
php bin/magento cache:flush

Hope this helps you to sort out your issue.

  • This works, thanks for your help. – Eric Brown Mar 29 at 16:21

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.