Having trouble overwriting JS component in minicart dropdown












0














Having a tough time trying to overwrite the JS component and template around the product image in the minicart dropdown.Here's what I am trying to achieve:



I have a custom Product Type depending on the users selection, a different photo should appear in this minicart dropdown. To do this, I will need access to the current quote and product from the JS component.



I have identified the template and component is specified in
Magento_Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml:



<item name="children" xsi:type="array">
<item name="item.image" xsi:type="array">
<item name="component" xsi:type="string">Magento_Catalog/js/view/image</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_Catalog/product/image</item>
<item name="displayArea" xsi:type="string">itemImage</item>
</item>
</item>




Which points to template Magento_Catalog/web/template/product/image_with_borders.html and component Magento_Catalog/js/view/image.



I have already written a custom endpoint elsewhere that will return the correct image based on a quote ID and product ID. So I need to extend Magento_Catalog/js/view/image to call this endpoint and bind it to the image's "src" property.



I want to do things "the Magento way" so I have tried using a "mixin" to extend Magento_Catalog/js/view/image, this just doesn't appear to work, no error but no calls to my file or any logging.



I have also attempted to simply update the <item name="component" xsi:type="string"></item> from checkout_cart_sidebar_item_renderers.xml to my chosen component path:



Convert_GivexAW/js/view/product/giftcard


But this produces the error:




[ERROR] Failed to load the "Convert_GivexAW/js/view/product/giftcard" component.




Here is my Convert/GivexAW/view/frontend/requirejs-config.js:



var config = {
map: {
'*': {
"Convert_GivexAW/js/view/product/giftcard": "Convert_GivexAW/js/view/product/giftcard"
}
}
};


The path to the file is: app/code/Convert/GivexAW/view/frontend/web/js/view/product/giftcard.js



Where am I going wrong? What is the correct approach to extend this component?



Thanks










share|improve this question






















  • For the 2nd case, you may try to enter JS component path (without .js) directly into the checkout_cart_sidebar_item_renderers.xml. <item name="component" xsi:type="string">Company_Module/js/view/product/giftcard</item>
    – Pritam Info 24
    Dec 21 '18 at 11:15
















0














Having a tough time trying to overwrite the JS component and template around the product image in the minicart dropdown.Here's what I am trying to achieve:



I have a custom Product Type depending on the users selection, a different photo should appear in this minicart dropdown. To do this, I will need access to the current quote and product from the JS component.



I have identified the template and component is specified in
Magento_Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml:



<item name="children" xsi:type="array">
<item name="item.image" xsi:type="array">
<item name="component" xsi:type="string">Magento_Catalog/js/view/image</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_Catalog/product/image</item>
<item name="displayArea" xsi:type="string">itemImage</item>
</item>
</item>




Which points to template Magento_Catalog/web/template/product/image_with_borders.html and component Magento_Catalog/js/view/image.



I have already written a custom endpoint elsewhere that will return the correct image based on a quote ID and product ID. So I need to extend Magento_Catalog/js/view/image to call this endpoint and bind it to the image's "src" property.



I want to do things "the Magento way" so I have tried using a "mixin" to extend Magento_Catalog/js/view/image, this just doesn't appear to work, no error but no calls to my file or any logging.



I have also attempted to simply update the <item name="component" xsi:type="string"></item> from checkout_cart_sidebar_item_renderers.xml to my chosen component path:



Convert_GivexAW/js/view/product/giftcard


But this produces the error:




[ERROR] Failed to load the "Convert_GivexAW/js/view/product/giftcard" component.




Here is my Convert/GivexAW/view/frontend/requirejs-config.js:



var config = {
map: {
'*': {
"Convert_GivexAW/js/view/product/giftcard": "Convert_GivexAW/js/view/product/giftcard"
}
}
};


The path to the file is: app/code/Convert/GivexAW/view/frontend/web/js/view/product/giftcard.js



Where am I going wrong? What is the correct approach to extend this component?



Thanks










share|improve this question






















  • For the 2nd case, you may try to enter JS component path (without .js) directly into the checkout_cart_sidebar_item_renderers.xml. <item name="component" xsi:type="string">Company_Module/js/view/product/giftcard</item>
    – Pritam Info 24
    Dec 21 '18 at 11:15














0












0








0


1





Having a tough time trying to overwrite the JS component and template around the product image in the minicart dropdown.Here's what I am trying to achieve:



I have a custom Product Type depending on the users selection, a different photo should appear in this minicart dropdown. To do this, I will need access to the current quote and product from the JS component.



I have identified the template and component is specified in
Magento_Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml:



<item name="children" xsi:type="array">
<item name="item.image" xsi:type="array">
<item name="component" xsi:type="string">Magento_Catalog/js/view/image</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_Catalog/product/image</item>
<item name="displayArea" xsi:type="string">itemImage</item>
</item>
</item>




Which points to template Magento_Catalog/web/template/product/image_with_borders.html and component Magento_Catalog/js/view/image.



I have already written a custom endpoint elsewhere that will return the correct image based on a quote ID and product ID. So I need to extend Magento_Catalog/js/view/image to call this endpoint and bind it to the image's "src" property.



I want to do things "the Magento way" so I have tried using a "mixin" to extend Magento_Catalog/js/view/image, this just doesn't appear to work, no error but no calls to my file or any logging.



I have also attempted to simply update the <item name="component" xsi:type="string"></item> from checkout_cart_sidebar_item_renderers.xml to my chosen component path:



Convert_GivexAW/js/view/product/giftcard


But this produces the error:




[ERROR] Failed to load the "Convert_GivexAW/js/view/product/giftcard" component.




Here is my Convert/GivexAW/view/frontend/requirejs-config.js:



var config = {
map: {
'*': {
"Convert_GivexAW/js/view/product/giftcard": "Convert_GivexAW/js/view/product/giftcard"
}
}
};


The path to the file is: app/code/Convert/GivexAW/view/frontend/web/js/view/product/giftcard.js



Where am I going wrong? What is the correct approach to extend this component?



Thanks










share|improve this question













Having a tough time trying to overwrite the JS component and template around the product image in the minicart dropdown.Here's what I am trying to achieve:



I have a custom Product Type depending on the users selection, a different photo should appear in this minicart dropdown. To do this, I will need access to the current quote and product from the JS component.



I have identified the template and component is specified in
Magento_Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml:



<item name="children" xsi:type="array">
<item name="item.image" xsi:type="array">
<item name="component" xsi:type="string">Magento_Catalog/js/view/image</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Magento_Catalog/product/image</item>
<item name="displayArea" xsi:type="string">itemImage</item>
</item>
</item>




Which points to template Magento_Catalog/web/template/product/image_with_borders.html and component Magento_Catalog/js/view/image.



I have already written a custom endpoint elsewhere that will return the correct image based on a quote ID and product ID. So I need to extend Magento_Catalog/js/view/image to call this endpoint and bind it to the image's "src" property.



I want to do things "the Magento way" so I have tried using a "mixin" to extend Magento_Catalog/js/view/image, this just doesn't appear to work, no error but no calls to my file or any logging.



I have also attempted to simply update the <item name="component" xsi:type="string"></item> from checkout_cart_sidebar_item_renderers.xml to my chosen component path:



Convert_GivexAW/js/view/product/giftcard


But this produces the error:




[ERROR] Failed to load the "Convert_GivexAW/js/view/product/giftcard" component.




Here is my Convert/GivexAW/view/frontend/requirejs-config.js:



var config = {
map: {
'*': {
"Convert_GivexAW/js/view/product/giftcard": "Convert_GivexAW/js/view/product/giftcard"
}
}
};


The path to the file is: app/code/Convert/GivexAW/view/frontend/web/js/view/product/giftcard.js



Where am I going wrong? What is the correct approach to extend this component?



Thanks







magento2 uicomponent requirejs knockout






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 21 '18 at 1:37









Chris RogersChris Rogers

228210




228210












  • For the 2nd case, you may try to enter JS component path (without .js) directly into the checkout_cart_sidebar_item_renderers.xml. <item name="component" xsi:type="string">Company_Module/js/view/product/giftcard</item>
    – Pritam Info 24
    Dec 21 '18 at 11:15


















  • For the 2nd case, you may try to enter JS component path (without .js) directly into the checkout_cart_sidebar_item_renderers.xml. <item name="component" xsi:type="string">Company_Module/js/view/product/giftcard</item>
    – Pritam Info 24
    Dec 21 '18 at 11:15
















For the 2nd case, you may try to enter JS component path (without .js) directly into the checkout_cart_sidebar_item_renderers.xml. <item name="component" xsi:type="string">Company_Module/js/view/product/giftcard</item>
– Pritam Info 24
Dec 21 '18 at 11:15




For the 2nd case, you may try to enter JS component path (without .js) directly into the checkout_cart_sidebar_item_renderers.xml. <item name="component" xsi:type="string">Company_Module/js/view/product/giftcard</item>
– Pritam Info 24
Dec 21 '18 at 11:15










2 Answers
2






active

oldest

votes


















1














You try below mixin code to extend Magento_Catalog/js/view/image



I assume you are using a custom theme "Vendor_theme".



step 1)



Define requirejs-config.js under



/app/design/frontend/Vendor/theme/Magento_Catalog/



File : requirejs-config.js



var config = {
config: {
mixins: {
'Magento_Catalog/js/view/image':
{'Magento_Catalog/js/view/image-mixin': true},
},

},
};


step 2)



create image-mixin.js under



/app/design/frontend/Vendor/theme/Magento_Catalog/web/js/view/



File : image-mixin.js



console.log('init image-mixin.js');
define(, function () {
'use strict';

return function (Form) {
return Form.extend({
initialize: function () {
this._super();
console.log('Hello from the mixin!');
}
});
}
});


step 3) Run below Commands to remove static content



sudo rm -rf var/view_preprocessed/*
sudo rm -rf var/pub/static/*
sudo rm -rf var/cache/*
sudo rm -rf var/generated
sudo rm -rf var/composer_home
sudo rm -rf var/page_cache
sudo rm -rf var/view_preprocessed
sudo rm -rf pub/static/frontend/*


Now you should see the console log for image-mixin.js .






share|improve this answer





















  • Thank you, I will try this ASAP and get back to you!
    – Chris Rogers
    Dec 22 '18 at 17:47










  • Sorry @Pritam Info 24 this didn't work, I managed to fix it using Magento's recently updated doc: devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/…
    – Chris Rogers
    yesterday



















0














So Magento recently updated the doc on Mixin's which can be found here:
https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/js_mixins.html which appears to be the only example I could find that works. As a run down, here is a boilerplate of the required scripts for JS Mixins:



requirejs-config.js



var config = {
map: {
'*': {}
},
config: {
mixins: {
'Magento_Catalog/js/view/image': {
'My_Module/js/view/product/image-mixin': true
}
}
}
};


app/code/My/Module/view/frontend/web/js/view/product/image-mixin.js



define([
'jquery',
'ko',
'uiComponent'
], function ($, ko, Component) {
'use strict';

var mixin = {

/**
* @var {string} imgSrc
*/
imgSrc: "blah",

/**
* Initialization method
*/
initialize: function () {
this._super();
console.log("MIXIN");
$(document).ready(() => {
console.log("READY");
});
}
};

return function (target) { // target == Result that Magento_Catalog/js/view/image returns.
return target.extend(mixin); // New result that all other modules receive
};
});


Then from within the mixin object, you can add additional / overwrite existing methods.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f255423%2fhaving-trouble-overwriting-js-component-in-minicart-dropdown%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You try below mixin code to extend Magento_Catalog/js/view/image



    I assume you are using a custom theme "Vendor_theme".



    step 1)



    Define requirejs-config.js under



    /app/design/frontend/Vendor/theme/Magento_Catalog/



    File : requirejs-config.js



    var config = {
    config: {
    mixins: {
    'Magento_Catalog/js/view/image':
    {'Magento_Catalog/js/view/image-mixin': true},
    },

    },
    };


    step 2)



    create image-mixin.js under



    /app/design/frontend/Vendor/theme/Magento_Catalog/web/js/view/



    File : image-mixin.js



    console.log('init image-mixin.js');
    define(, function () {
    'use strict';

    return function (Form) {
    return Form.extend({
    initialize: function () {
    this._super();
    console.log('Hello from the mixin!');
    }
    });
    }
    });


    step 3) Run below Commands to remove static content



    sudo rm -rf var/view_preprocessed/*
    sudo rm -rf var/pub/static/*
    sudo rm -rf var/cache/*
    sudo rm -rf var/generated
    sudo rm -rf var/composer_home
    sudo rm -rf var/page_cache
    sudo rm -rf var/view_preprocessed
    sudo rm -rf pub/static/frontend/*


    Now you should see the console log for image-mixin.js .






    share|improve this answer





















    • Thank you, I will try this ASAP and get back to you!
      – Chris Rogers
      Dec 22 '18 at 17:47










    • Sorry @Pritam Info 24 this didn't work, I managed to fix it using Magento's recently updated doc: devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/…
      – Chris Rogers
      yesterday
















    1














    You try below mixin code to extend Magento_Catalog/js/view/image



    I assume you are using a custom theme "Vendor_theme".



    step 1)



    Define requirejs-config.js under



    /app/design/frontend/Vendor/theme/Magento_Catalog/



    File : requirejs-config.js



    var config = {
    config: {
    mixins: {
    'Magento_Catalog/js/view/image':
    {'Magento_Catalog/js/view/image-mixin': true},
    },

    },
    };


    step 2)



    create image-mixin.js under



    /app/design/frontend/Vendor/theme/Magento_Catalog/web/js/view/



    File : image-mixin.js



    console.log('init image-mixin.js');
    define(, function () {
    'use strict';

    return function (Form) {
    return Form.extend({
    initialize: function () {
    this._super();
    console.log('Hello from the mixin!');
    }
    });
    }
    });


    step 3) Run below Commands to remove static content



    sudo rm -rf var/view_preprocessed/*
    sudo rm -rf var/pub/static/*
    sudo rm -rf var/cache/*
    sudo rm -rf var/generated
    sudo rm -rf var/composer_home
    sudo rm -rf var/page_cache
    sudo rm -rf var/view_preprocessed
    sudo rm -rf pub/static/frontend/*


    Now you should see the console log for image-mixin.js .






    share|improve this answer





















    • Thank you, I will try this ASAP and get back to you!
      – Chris Rogers
      Dec 22 '18 at 17:47










    • Sorry @Pritam Info 24 this didn't work, I managed to fix it using Magento's recently updated doc: devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/…
      – Chris Rogers
      yesterday














    1












    1








    1






    You try below mixin code to extend Magento_Catalog/js/view/image



    I assume you are using a custom theme "Vendor_theme".



    step 1)



    Define requirejs-config.js under



    /app/design/frontend/Vendor/theme/Magento_Catalog/



    File : requirejs-config.js



    var config = {
    config: {
    mixins: {
    'Magento_Catalog/js/view/image':
    {'Magento_Catalog/js/view/image-mixin': true},
    },

    },
    };


    step 2)



    create image-mixin.js under



    /app/design/frontend/Vendor/theme/Magento_Catalog/web/js/view/



    File : image-mixin.js



    console.log('init image-mixin.js');
    define(, function () {
    'use strict';

    return function (Form) {
    return Form.extend({
    initialize: function () {
    this._super();
    console.log('Hello from the mixin!');
    }
    });
    }
    });


    step 3) Run below Commands to remove static content



    sudo rm -rf var/view_preprocessed/*
    sudo rm -rf var/pub/static/*
    sudo rm -rf var/cache/*
    sudo rm -rf var/generated
    sudo rm -rf var/composer_home
    sudo rm -rf var/page_cache
    sudo rm -rf var/view_preprocessed
    sudo rm -rf pub/static/frontend/*


    Now you should see the console log for image-mixin.js .






    share|improve this answer












    You try below mixin code to extend Magento_Catalog/js/view/image



    I assume you are using a custom theme "Vendor_theme".



    step 1)



    Define requirejs-config.js under



    /app/design/frontend/Vendor/theme/Magento_Catalog/



    File : requirejs-config.js



    var config = {
    config: {
    mixins: {
    'Magento_Catalog/js/view/image':
    {'Magento_Catalog/js/view/image-mixin': true},
    },

    },
    };


    step 2)



    create image-mixin.js under



    /app/design/frontend/Vendor/theme/Magento_Catalog/web/js/view/



    File : image-mixin.js



    console.log('init image-mixin.js');
    define(, function () {
    'use strict';

    return function (Form) {
    return Form.extend({
    initialize: function () {
    this._super();
    console.log('Hello from the mixin!');
    }
    });
    }
    });


    step 3) Run below Commands to remove static content



    sudo rm -rf var/view_preprocessed/*
    sudo rm -rf var/pub/static/*
    sudo rm -rf var/cache/*
    sudo rm -rf var/generated
    sudo rm -rf var/composer_home
    sudo rm -rf var/page_cache
    sudo rm -rf var/view_preprocessed
    sudo rm -rf pub/static/frontend/*


    Now you should see the console log for image-mixin.js .







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 21 '18 at 12:45









    Pritam Info 24Pritam Info 24

    6147




    6147












    • Thank you, I will try this ASAP and get back to you!
      – Chris Rogers
      Dec 22 '18 at 17:47










    • Sorry @Pritam Info 24 this didn't work, I managed to fix it using Magento's recently updated doc: devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/…
      – Chris Rogers
      yesterday


















    • Thank you, I will try this ASAP and get back to you!
      – Chris Rogers
      Dec 22 '18 at 17:47










    • Sorry @Pritam Info 24 this didn't work, I managed to fix it using Magento's recently updated doc: devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/…
      – Chris Rogers
      yesterday
















    Thank you, I will try this ASAP and get back to you!
    – Chris Rogers
    Dec 22 '18 at 17:47




    Thank you, I will try this ASAP and get back to you!
    – Chris Rogers
    Dec 22 '18 at 17:47












    Sorry @Pritam Info 24 this didn't work, I managed to fix it using Magento's recently updated doc: devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/…
    – Chris Rogers
    yesterday




    Sorry @Pritam Info 24 this didn't work, I managed to fix it using Magento's recently updated doc: devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/…
    – Chris Rogers
    yesterday













    0














    So Magento recently updated the doc on Mixin's which can be found here:
    https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/js_mixins.html which appears to be the only example I could find that works. As a run down, here is a boilerplate of the required scripts for JS Mixins:



    requirejs-config.js



    var config = {
    map: {
    '*': {}
    },
    config: {
    mixins: {
    'Magento_Catalog/js/view/image': {
    'My_Module/js/view/product/image-mixin': true
    }
    }
    }
    };


    app/code/My/Module/view/frontend/web/js/view/product/image-mixin.js



    define([
    'jquery',
    'ko',
    'uiComponent'
    ], function ($, ko, Component) {
    'use strict';

    var mixin = {

    /**
    * @var {string} imgSrc
    */
    imgSrc: "blah",

    /**
    * Initialization method
    */
    initialize: function () {
    this._super();
    console.log("MIXIN");
    $(document).ready(() => {
    console.log("READY");
    });
    }
    };

    return function (target) { // target == Result that Magento_Catalog/js/view/image returns.
    return target.extend(mixin); // New result that all other modules receive
    };
    });


    Then from within the mixin object, you can add additional / overwrite existing methods.






    share|improve this answer


























      0














      So Magento recently updated the doc on Mixin's which can be found here:
      https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/js_mixins.html which appears to be the only example I could find that works. As a run down, here is a boilerplate of the required scripts for JS Mixins:



      requirejs-config.js



      var config = {
      map: {
      '*': {}
      },
      config: {
      mixins: {
      'Magento_Catalog/js/view/image': {
      'My_Module/js/view/product/image-mixin': true
      }
      }
      }
      };


      app/code/My/Module/view/frontend/web/js/view/product/image-mixin.js



      define([
      'jquery',
      'ko',
      'uiComponent'
      ], function ($, ko, Component) {
      'use strict';

      var mixin = {

      /**
      * @var {string} imgSrc
      */
      imgSrc: "blah",

      /**
      * Initialization method
      */
      initialize: function () {
      this._super();
      console.log("MIXIN");
      $(document).ready(() => {
      console.log("READY");
      });
      }
      };

      return function (target) { // target == Result that Magento_Catalog/js/view/image returns.
      return target.extend(mixin); // New result that all other modules receive
      };
      });


      Then from within the mixin object, you can add additional / overwrite existing methods.






      share|improve this answer
























        0












        0








        0






        So Magento recently updated the doc on Mixin's which can be found here:
        https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/js_mixins.html which appears to be the only example I could find that works. As a run down, here is a boilerplate of the required scripts for JS Mixins:



        requirejs-config.js



        var config = {
        map: {
        '*': {}
        },
        config: {
        mixins: {
        'Magento_Catalog/js/view/image': {
        'My_Module/js/view/product/image-mixin': true
        }
        }
        }
        };


        app/code/My/Module/view/frontend/web/js/view/product/image-mixin.js



        define([
        'jquery',
        'ko',
        'uiComponent'
        ], function ($, ko, Component) {
        'use strict';

        var mixin = {

        /**
        * @var {string} imgSrc
        */
        imgSrc: "blah",

        /**
        * Initialization method
        */
        initialize: function () {
        this._super();
        console.log("MIXIN");
        $(document).ready(() => {
        console.log("READY");
        });
        }
        };

        return function (target) { // target == Result that Magento_Catalog/js/view/image returns.
        return target.extend(mixin); // New result that all other modules receive
        };
        });


        Then from within the mixin object, you can add additional / overwrite existing methods.






        share|improve this answer












        So Magento recently updated the doc on Mixin's which can be found here:
        https://devdocs.magento.com/guides/v2.3/javascript-dev-guide/javascript/js_mixins.html which appears to be the only example I could find that works. As a run down, here is a boilerplate of the required scripts for JS Mixins:



        requirejs-config.js



        var config = {
        map: {
        '*': {}
        },
        config: {
        mixins: {
        'Magento_Catalog/js/view/image': {
        'My_Module/js/view/product/image-mixin': true
        }
        }
        }
        };


        app/code/My/Module/view/frontend/web/js/view/product/image-mixin.js



        define([
        'jquery',
        'ko',
        'uiComponent'
        ], function ($, ko, Component) {
        'use strict';

        var mixin = {

        /**
        * @var {string} imgSrc
        */
        imgSrc: "blah",

        /**
        * Initialization method
        */
        initialize: function () {
        this._super();
        console.log("MIXIN");
        $(document).ready(() => {
        console.log("READY");
        });
        }
        };

        return function (target) { // target == Result that Magento_Catalog/js/view/image returns.
        return target.extend(mixin); // New result that all other modules receive
        };
        });


        Then from within the mixin object, you can add additional / overwrite existing methods.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        Chris RogersChris Rogers

        228210




        228210






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f255423%2fhaving-trouble-overwriting-js-component-in-minicart-dropdown%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            An IMO inspired problem

            Management

            Has there ever been an instance of an active nuclear power plant within or near a war zone?