1

I want to override following js core file.

public_html/vendor/magento/module-configurable-product/view/frontend

I have tried in my custom theme as follow but it is not working

public_html/app/design/frontend/TemplateMonster/theme007/Magento_ConfigurableProduct/view/frontend/web/js

i have also created required requirejs-config.js and added following code

/public_html/app/design/frontend/TemplateMonster/theme007/Magento_ConfigurableProduct/requirejs-config.js

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

Need to run :

rm -rf var/generation/ var/view_preprocessed/ pub/static/frontend/ pub/static/_requirejs/ var/cache var/di var/page_cache pub/static/_cache

./bin/magento setup:static-content:deploy

0

If you want to override at theme level then don't need anything. Donot require requirejs-config.js at app/design/frontend/TemplateMonster/theme007/Magento_ConfigurableProduct/requirejs-config.js

Just put configurable.js at app/design/frontend/TemplateMonster/theme007/Magento_ConfigurableProduct/web/js.Means file name should same with core file and same location.

After that do Static content deploy.It must required.

0

Firstly, you need to make sure, that your module has Magento_ConfigurableProduct in sequence in module.xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_ModuleName" setup_version="1.0.0">
        <sequence>
            <module name="Magento_ConfigurableProduct"/>
        </sequence>
    </module>
</config>

Then add requirejs-config.js file in view/frontend directory with code:

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

Finally add configurable.js file in view/frontend/web/js directory with:

define([
    'jquery',
    'jquery/ui',
    'Magento_ConfigurableProduct/js/configurable'
], function($){

    $.widget('silvan.configurable', $.mage.configurable, {
        //code you want to override
    });

    return $.silvan.configurable;
});

Run this Commands :

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento cache:flush

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.