4

Without editing the core file, I want to add some code to minicart.js so I tried overriding the minicart.js file in my theme by this:

var/www/animals/app/design/frontend/Dogs/husky/Magento_Checkout/web/js/view/minicart.js

But it did not work? Am I doing something wrong?

THANKS!

  • 1
    Try deleting static content using rm -rf pub/static/* var/view_preprocessed/* and flush the cache. You'll need to redeploy static content if you're in production mode. – Aaron Allen May 23 '17 at 23:02
5

You'd better extend the minicart component. For example:

app/code/vendor/module/view/frontend/requirejs-config.js

var config = {
    'config': {
        'mixins': {
            'Magento_Checkout/js/view/minicart': {
                'Storefront_Bootstrap/js/checkout/view/minicart': true
            }
        }
    }
};

app/code/vendor/module/view/frontend/web/js/checkout/view/minicart.js

/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

define([
], function () {
    'use strict';

    return function (Component) {
        return Component.extend({

            /**
             * @override
             */
            initialize: function () {
                var self = this;

                return this._super();
            },
        });
    }
});

More info here and study more about jquery ui-components for extra help below:

http://devdocs.magento.com/guides/v2.0/ui-components/ui-component.html http://devdocs.magento.com/guides/v2.2/ui_comp_guide/bk-ui_comps.html http://devdocs.magento.com/guides/v2.2/ui_comp_guide/bk-ui_comps.html

  • I follow the same steps and extended closing event in minicart.js but it's not working. – Sunny Khatri May 10 '18 at 4:49
  • Can you describe your problem a bit more (with code fragments and such) please? – Quisse May 14 '18 at 7:38
  • 2
    The filename is not requirejs.config, it's requirejs-config.js – BrianVPS Jul 3 '18 at 17:55
  • Thx for reporting, updated. – Quisse Jul 4 '18 at 7: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.