5

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
  • 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. Commented May 23, 2017 at 23:02

1 Answer 1

8

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': {
                'Vendor_Module/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

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

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.