0

I'm trying to make some changes to the configurable product dropdowns in the front end product display on Magento 2.1.0. I want to do this through re-writing the configurable javascript widget.

I created a requirejs-config.js in app/code/myMod/blah/view/frontend/requirejs-config.js. It looks like this:


var config = {
  map: {
    '*': {
      configurable: 'myMod_blah/js/configurable'
    }
  }
};

I have my new copy (with just one line added so I can recognize it) of the configurable.js file here: app/code/myMod/blah/view/frontend/web/js/configurable.js

When I look at the contents of the requirejs-config.js file on the page I can see my config very close to the top, but then near the bottom is still the old config that looks like:


var config = {
    map: {
        '*': {
            configurable: 'Magento_ConfigurableProduct/js/configurable'
        }
    }
};

And, when I look at the contents of the configurable.js file in the source of the loaded page, sure enough, it's the magento default version, not mine (it doesn't have the line I added).

What am I doing wrong?

Edit: I believe my question is directly related to this previous question, which has a workaround, but not an actual answer: Magento 2: How to override core js module price-bundle.js

Edit #2 - this work around works, when I preface my company/mod directories with zzmyMod and zzBlah, the correct js file shows up, because, as I guessed, it is added to requirejs-config.js AFTER all the magento stuff instead of before and therefore gets processed after magentos own definition for "configurable." I'd still really like to know how to fix this because I don't like naming my module this way.

8
  • Magento version ? Commented Sep 8, 2016 at 16:07
  • Have you applied below solution or not ? Commented Sep 8, 2016 at 16:32
  • Please, update your question with the code lines of this file also: app/code/myMod/blah/view/frontend/web/js/configurable.js Commented Sep 8, 2016 at 16:36
  • Yes, I ran your suggested commands. No change. I'm pretty sure it has no hope of working correctly if there is are two competing definition on the requirejs-config.js file. Since Magento's default definition appears later in the file, it is the last one processed. How do I prevent theirs from overriding mine?
    – Todd
    Commented Sep 8, 2016 at 16:36
  • @KhoaTruongDinh Update it? I added my own line of code to it before I ftp'ed it into place. Do you want me to change it again?
    – Todd
    Commented Sep 8, 2016 at 16:38

1 Answer 1

0

You have to deploy static content to see your changes.

Run bellow command for deploy static content

php bin/magento setup:static-content:deploy

and

php bin/magento cache:clean

Now you can check your changes.

7
  • I have my magento software in development mode - it was my impression that there is no need to clean caches when using this mode. In any case, I have run the commands you suggested, and cleared my browsers cache. It still is using the old version of the configurable.js file.
    – Todd
    Commented Sep 8, 2016 at 16:33
  • check you file in this path pub\static\frontend\YourTheme\Package\en_US\Magento_Authorizenet\js Commented Sep 8, 2016 at 16:37
  • cache must be need to clean when if it enable from admin. please also clean cahce Commented Sep 8, 2016 at 16:38
  • I've cleaned the cache exactly as you asked, in the order you said to do it.
    – Todd
    Commented Sep 8, 2016 at 16:40
  • Have you checked file in above file ? Commented Sep 8, 2016 at 16:47

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.