Magento 2: How to override core js module price-bundle.js
I am attempting to override the _onQtyFieldChanged
event in the mage.priceBundle
widget in the module-bundle/view/base/web/js/price-bundle.js
file.
I am referencing the Magento dev docs (http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html) and this Magento StackExchange question (Magento2: How can I override core js module price-box.js), but I can't manage to get my custom _onQtyFieldChanged
event method to execute. As of now I only have a console.log
statement in that method.
A little background:
My custom price-bundle.js
file is found in Endertech/BundleExtended/view/base/web/js
directory.
My requirejs-config.js
is in Endertech/BundleExtended/view/frontend
.
requirejs-config.js
:
var config = {
map: {
"*": {
priceBundle: 'Endertech_BundleExtended/js/price-bundle',
'Magento_Bundle/js/price-bundle': 'Endertech_BundleExtended/js/price-bundle'
}
}
};
Endertech/BundleExtended/view/base/web/js/price-bundle.js
:
define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox',
'priceBundle',
], function ($, _, mageTemplate, utils) {
'use strict';
$.widget('Endertech.priceBundle', $.mage.priceBundle, {
_onQtyFieldChanged: function onQtyFieldChanged(event) {
console.log("Endertech Module");
var field = $(event.target),
optionInstance,
optionConfig;
if (field.data('optionId') && field.data('optionValueId')) {
optionInstance = field.data('option');
optionConfig = this.options.optionConfig
.options[field.data('optionId')]
.selections[field.data('optionValueId')];
optionConfig.qty = field.val();
optionInstance.trigger('change');
}
}
});
return $.Endertech.priceBundle;
});
EDIT:
So I realized that probably the issue I am coming across is the fact that the widget method I am trying to modify is a private method in module-bundle/view/base/web/js/price-bundle.js
. Which is the reason why I can't override it or extend it. I am not sure if there is a way to get around this or a different approach I need to take to this issue that I don't know about.
Any help and suggestions are greatly appreciated.
magento2 javascript overrides magento-2.0 requirejs
add a comment |
I am attempting to override the _onQtyFieldChanged
event in the mage.priceBundle
widget in the module-bundle/view/base/web/js/price-bundle.js
file.
I am referencing the Magento dev docs (http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html) and this Magento StackExchange question (Magento2: How can I override core js module price-box.js), but I can't manage to get my custom _onQtyFieldChanged
event method to execute. As of now I only have a console.log
statement in that method.
A little background:
My custom price-bundle.js
file is found in Endertech/BundleExtended/view/base/web/js
directory.
My requirejs-config.js
is in Endertech/BundleExtended/view/frontend
.
requirejs-config.js
:
var config = {
map: {
"*": {
priceBundle: 'Endertech_BundleExtended/js/price-bundle',
'Magento_Bundle/js/price-bundle': 'Endertech_BundleExtended/js/price-bundle'
}
}
};
Endertech/BundleExtended/view/base/web/js/price-bundle.js
:
define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox',
'priceBundle',
], function ($, _, mageTemplate, utils) {
'use strict';
$.widget('Endertech.priceBundle', $.mage.priceBundle, {
_onQtyFieldChanged: function onQtyFieldChanged(event) {
console.log("Endertech Module");
var field = $(event.target),
optionInstance,
optionConfig;
if (field.data('optionId') && field.data('optionValueId')) {
optionInstance = field.data('option');
optionConfig = this.options.optionConfig
.options[field.data('optionId')]
.selections[field.data('optionValueId')];
optionConfig.qty = field.val();
optionInstance.trigger('change');
}
}
});
return $.Endertech.priceBundle;
});
EDIT:
So I realized that probably the issue I am coming across is the fact that the widget method I am trying to modify is a private method in module-bundle/view/base/web/js/price-bundle.js
. Which is the reason why I can't override it or extend it. I am not sure if there is a way to get around this or a different approach I need to take to this issue that I don't know about.
Any help and suggestions are greatly appreciated.
magento2 javascript overrides magento-2.0 requirejs
1
We may have architecture for this. Checking.
– benmarks♦
Jun 7 '16 at 16:06
2
Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.
– benmarks♦
Jun 8 '16 at 15:34
@benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the$.mage.priceBundle
parameters and methods.
– Noemi Quezada
Jun 8 '16 at 21:26
@NoemiQuezada Please mark the correct answer
– Stevie G
Jan 13 '17 at 15:00
Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it
– Himanshu
56 mins ago
add a comment |
I am attempting to override the _onQtyFieldChanged
event in the mage.priceBundle
widget in the module-bundle/view/base/web/js/price-bundle.js
file.
I am referencing the Magento dev docs (http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html) and this Magento StackExchange question (Magento2: How can I override core js module price-box.js), but I can't manage to get my custom _onQtyFieldChanged
event method to execute. As of now I only have a console.log
statement in that method.
A little background:
My custom price-bundle.js
file is found in Endertech/BundleExtended/view/base/web/js
directory.
My requirejs-config.js
is in Endertech/BundleExtended/view/frontend
.
requirejs-config.js
:
var config = {
map: {
"*": {
priceBundle: 'Endertech_BundleExtended/js/price-bundle',
'Magento_Bundle/js/price-bundle': 'Endertech_BundleExtended/js/price-bundle'
}
}
};
Endertech/BundleExtended/view/base/web/js/price-bundle.js
:
define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox',
'priceBundle',
], function ($, _, mageTemplate, utils) {
'use strict';
$.widget('Endertech.priceBundle', $.mage.priceBundle, {
_onQtyFieldChanged: function onQtyFieldChanged(event) {
console.log("Endertech Module");
var field = $(event.target),
optionInstance,
optionConfig;
if (field.data('optionId') && field.data('optionValueId')) {
optionInstance = field.data('option');
optionConfig = this.options.optionConfig
.options[field.data('optionId')]
.selections[field.data('optionValueId')];
optionConfig.qty = field.val();
optionInstance.trigger('change');
}
}
});
return $.Endertech.priceBundle;
});
EDIT:
So I realized that probably the issue I am coming across is the fact that the widget method I am trying to modify is a private method in module-bundle/view/base/web/js/price-bundle.js
. Which is the reason why I can't override it or extend it. I am not sure if there is a way to get around this or a different approach I need to take to this issue that I don't know about.
Any help and suggestions are greatly appreciated.
magento2 javascript overrides magento-2.0 requirejs
I am attempting to override the _onQtyFieldChanged
event in the mage.priceBundle
widget in the module-bundle/view/base/web/js/price-bundle.js
file.
I am referencing the Magento dev docs (http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html) and this Magento StackExchange question (Magento2: How can I override core js module price-box.js), but I can't manage to get my custom _onQtyFieldChanged
event method to execute. As of now I only have a console.log
statement in that method.
A little background:
My custom price-bundle.js
file is found in Endertech/BundleExtended/view/base/web/js
directory.
My requirejs-config.js
is in Endertech/BundleExtended/view/frontend
.
requirejs-config.js
:
var config = {
map: {
"*": {
priceBundle: 'Endertech_BundleExtended/js/price-bundle',
'Magento_Bundle/js/price-bundle': 'Endertech_BundleExtended/js/price-bundle'
}
}
};
Endertech/BundleExtended/view/base/web/js/price-bundle.js
:
define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox',
'priceBundle',
], function ($, _, mageTemplate, utils) {
'use strict';
$.widget('Endertech.priceBundle', $.mage.priceBundle, {
_onQtyFieldChanged: function onQtyFieldChanged(event) {
console.log("Endertech Module");
var field = $(event.target),
optionInstance,
optionConfig;
if (field.data('optionId') && field.data('optionValueId')) {
optionInstance = field.data('option');
optionConfig = this.options.optionConfig
.options[field.data('optionId')]
.selections[field.data('optionValueId')];
optionConfig.qty = field.val();
optionInstance.trigger('change');
}
}
});
return $.Endertech.priceBundle;
});
EDIT:
So I realized that probably the issue I am coming across is the fact that the widget method I am trying to modify is a private method in module-bundle/view/base/web/js/price-bundle.js
. Which is the reason why I can't override it or extend it. I am not sure if there is a way to get around this or a different approach I need to take to this issue that I don't know about.
Any help and suggestions are greatly appreciated.
magento2 javascript overrides magento-2.0 requirejs
magento2 javascript overrides magento-2.0 requirejs
edited Jun 6 '16 at 19:23
Noemi Quezada
asked Jun 2 '16 at 22:09
Noemi QuezadaNoemi Quezada
494729
494729
1
We may have architecture for this. Checking.
– benmarks♦
Jun 7 '16 at 16:06
2
Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.
– benmarks♦
Jun 8 '16 at 15:34
@benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the$.mage.priceBundle
parameters and methods.
– Noemi Quezada
Jun 8 '16 at 21:26
@NoemiQuezada Please mark the correct answer
– Stevie G
Jan 13 '17 at 15:00
Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it
– Himanshu
56 mins ago
add a comment |
1
We may have architecture for this. Checking.
– benmarks♦
Jun 7 '16 at 16:06
2
Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.
– benmarks♦
Jun 8 '16 at 15:34
@benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the$.mage.priceBundle
parameters and methods.
– Noemi Quezada
Jun 8 '16 at 21:26
@NoemiQuezada Please mark the correct answer
– Stevie G
Jan 13 '17 at 15:00
Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it
– Himanshu
56 mins ago
1
1
We may have architecture for this. Checking.
– benmarks♦
Jun 7 '16 at 16:06
We may have architecture for this. Checking.
– benmarks♦
Jun 7 '16 at 16:06
2
2
Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.
– benmarks♦
Jun 8 '16 at 15:34
Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.
– benmarks♦
Jun 8 '16 at 15:34
@benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the
$.mage.priceBundle
parameters and methods.– Noemi Quezada
Jun 8 '16 at 21:26
@benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the
$.mage.priceBundle
parameters and methods.– Noemi Quezada
Jun 8 '16 at 21:26
@NoemiQuezada Please mark the correct answer
– Stevie G
Jan 13 '17 at 15:00
@NoemiQuezada Please mark the correct answer
– Stevie G
Jan 13 '17 at 15:00
Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it
– Himanshu
56 mins ago
Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it
– Himanshu
56 mins ago
add a comment |
4 Answers
4
active
oldest
votes
I had the same issue like you and found a workaround, but don't know if it is helpful. I am going to share it anyway.
I resigned to override the function. Then I was trying to override the whole widget, but couldn't get it to work either. The widget wasn't overridden and the magento standard widget was loaded.
I inspected the generated pub/static/_requirejs/frontend/<Vendor>/<theme>/<location>/requirejs-config.js
file. It seems to me, that the modules' requirejs configurations are inserted in a alphabetical order. Thus, the priceBundle
variable of my module was overridden by the one of the magento-bundle module, because my vendor starts with a 'C'.
For testing purposes I created a new module and changed the vendor to 'XC...'. After that the overriding of the whole widget works.
But I am still interested in how to override just one function.
I tried this adding a Z in front of Endertech for the vendor name and now for the first time myprice-bundle.js
file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.
– Noemi Quezada
Jun 9 '16 at 19:47
I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.
– Densen
Jun 15 '16 at 8:48
add a comment |
You should intrude in requrejs sequence be adding dependencies for your extension, config will be:
var config = {
map: {
"*": {
priceBundle: 'SOURCE_TO_EXTENDED_PRICE_BUNDLE'
},
'Endertech_BundleExtended/js/price-bundle': {'priceBundle': 'SOURCE_TO_ORIGINAL_PRICE_BUNDLE'}
}
};
I tried this approach, but my file did not load at all.
– Noemi Quezada
Jun 9 '16 at 19:44
add a comment |
What I also found that worked was the following
In the module requirejs-config:
var config = {
map: {
'*': {
'mage/SwatchRenderer': 'Magento_Swatches/js/swatch-renderer',
'Magento_Swatches/js/swatch-renderer': 'MyVendor_MyModule/js/swatch-renderer'
}
}
};
And then I created a mymodule/view/frontend/web/js/swatch-renderer.js that contained:
define([
'jquery',
'jquery/ui',
'mage/SwatchRenderer',
], function ($) {
$.widget('myvendor.SwatchRenderer', $.mage.SwatchRenderer, {
_Rewind: function (controls) {
controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled');
controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled');
console.log('test');
},
});
return $.myvendor.SwatchRenderer;
});
add a comment |
If your core js use widget then you also call that widget and return that widget variable in a mixin.
Bundle mixin you have to create requirejs-config.js
in your custom module at
Vendor/Extension/view/frontend/requirejs-config.js
put below code in appropriate js
requirejs-config.js
:
var config = {
config: {
mixins: {
'Magento_Bundle/js/price-bundle': {
'Vendor_Extension/js/price-bundle-mixin': true
}
}
},
};
price-bundle-mixin
:
define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox'
], function ($, _, mageTemplate, utils) {
'use strict';
return function (priceBundle) {
$.widget('mage.priceBundle', priceBundle, {
// function which you want to overwrite
});
// don't forget to add a function which is used by your
// functions, else it will show undefined function error
return $.mage.priceBundle;
};
});
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f118153%2fmagento-2-how-to-override-core-js-module-price-bundle-js%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
I had the same issue like you and found a workaround, but don't know if it is helpful. I am going to share it anyway.
I resigned to override the function. Then I was trying to override the whole widget, but couldn't get it to work either. The widget wasn't overridden and the magento standard widget was loaded.
I inspected the generated pub/static/_requirejs/frontend/<Vendor>/<theme>/<location>/requirejs-config.js
file. It seems to me, that the modules' requirejs configurations are inserted in a alphabetical order. Thus, the priceBundle
variable of my module was overridden by the one of the magento-bundle module, because my vendor starts with a 'C'.
For testing purposes I created a new module and changed the vendor to 'XC...'. After that the overriding of the whole widget works.
But I am still interested in how to override just one function.
I tried this adding a Z in front of Endertech for the vendor name and now for the first time myprice-bundle.js
file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.
– Noemi Quezada
Jun 9 '16 at 19:47
I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.
– Densen
Jun 15 '16 at 8:48
add a comment |
I had the same issue like you and found a workaround, but don't know if it is helpful. I am going to share it anyway.
I resigned to override the function. Then I was trying to override the whole widget, but couldn't get it to work either. The widget wasn't overridden and the magento standard widget was loaded.
I inspected the generated pub/static/_requirejs/frontend/<Vendor>/<theme>/<location>/requirejs-config.js
file. It seems to me, that the modules' requirejs configurations are inserted in a alphabetical order. Thus, the priceBundle
variable of my module was overridden by the one of the magento-bundle module, because my vendor starts with a 'C'.
For testing purposes I created a new module and changed the vendor to 'XC...'. After that the overriding of the whole widget works.
But I am still interested in how to override just one function.
I tried this adding a Z in front of Endertech for the vendor name and now for the first time myprice-bundle.js
file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.
– Noemi Quezada
Jun 9 '16 at 19:47
I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.
– Densen
Jun 15 '16 at 8:48
add a comment |
I had the same issue like you and found a workaround, but don't know if it is helpful. I am going to share it anyway.
I resigned to override the function. Then I was trying to override the whole widget, but couldn't get it to work either. The widget wasn't overridden and the magento standard widget was loaded.
I inspected the generated pub/static/_requirejs/frontend/<Vendor>/<theme>/<location>/requirejs-config.js
file. It seems to me, that the modules' requirejs configurations are inserted in a alphabetical order. Thus, the priceBundle
variable of my module was overridden by the one of the magento-bundle module, because my vendor starts with a 'C'.
For testing purposes I created a new module and changed the vendor to 'XC...'. After that the overriding of the whole widget works.
But I am still interested in how to override just one function.
I had the same issue like you and found a workaround, but don't know if it is helpful. I am going to share it anyway.
I resigned to override the function. Then I was trying to override the whole widget, but couldn't get it to work either. The widget wasn't overridden and the magento standard widget was loaded.
I inspected the generated pub/static/_requirejs/frontend/<Vendor>/<theme>/<location>/requirejs-config.js
file. It seems to me, that the modules' requirejs configurations are inserted in a alphabetical order. Thus, the priceBundle
variable of my module was overridden by the one of the magento-bundle module, because my vendor starts with a 'C'.
For testing purposes I created a new module and changed the vendor to 'XC...'. After that the overriding of the whole widget works.
But I am still interested in how to override just one function.
edited Jun 9 '16 at 9:36
answered Jun 9 '16 at 9:17
DensenDensen
565
565
I tried this adding a Z in front of Endertech for the vendor name and now for the first time myprice-bundle.js
file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.
– Noemi Quezada
Jun 9 '16 at 19:47
I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.
– Densen
Jun 15 '16 at 8:48
add a comment |
I tried this adding a Z in front of Endertech for the vendor name and now for the first time myprice-bundle.js
file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.
– Noemi Quezada
Jun 9 '16 at 19:47
I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.
– Densen
Jun 15 '16 at 8:48
I tried this adding a Z in front of Endertech for the vendor name and now for the first time my
price-bundle.js
file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.– Noemi Quezada
Jun 9 '16 at 19:47
I tried this adding a Z in front of Endertech for the vendor name and now for the first time my
price-bundle.js
file gets loaded. Thank you! Like you though, I would like to understand how I can just override one method. However, after testing the solution I realized that another method has to be modified slightly because when you update a product that is in the cart the product summary is not updated correctly.– Noemi Quezada
Jun 9 '16 at 19:47
I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.
– Densen
Jun 15 '16 at 8:48
I'm glad that the workaround is working for you, too. Now, I'm wondering about the quantity of the radios when you update a product that is in the cart. It seams to me, that the quantity is being set to the default instead of to the user configured one. I did not changed anything about radios and can reproduce this behavior in other online demo shops. I already opened an issue at github: github.com/magento/magento2/issues/4942. Thus, don't waste your time, if you experience the same issue.
– Densen
Jun 15 '16 at 8:48
add a comment |
You should intrude in requrejs sequence be adding dependencies for your extension, config will be:
var config = {
map: {
"*": {
priceBundle: 'SOURCE_TO_EXTENDED_PRICE_BUNDLE'
},
'Endertech_BundleExtended/js/price-bundle': {'priceBundle': 'SOURCE_TO_ORIGINAL_PRICE_BUNDLE'}
}
};
I tried this approach, but my file did not load at all.
– Noemi Quezada
Jun 9 '16 at 19:44
add a comment |
You should intrude in requrejs sequence be adding dependencies for your extension, config will be:
var config = {
map: {
"*": {
priceBundle: 'SOURCE_TO_EXTENDED_PRICE_BUNDLE'
},
'Endertech_BundleExtended/js/price-bundle': {'priceBundle': 'SOURCE_TO_ORIGINAL_PRICE_BUNDLE'}
}
};
I tried this approach, but my file did not load at all.
– Noemi Quezada
Jun 9 '16 at 19:44
add a comment |
You should intrude in requrejs sequence be adding dependencies for your extension, config will be:
var config = {
map: {
"*": {
priceBundle: 'SOURCE_TO_EXTENDED_PRICE_BUNDLE'
},
'Endertech_BundleExtended/js/price-bundle': {'priceBundle': 'SOURCE_TO_ORIGINAL_PRICE_BUNDLE'}
}
};
You should intrude in requrejs sequence be adding dependencies for your extension, config will be:
var config = {
map: {
"*": {
priceBundle: 'SOURCE_TO_EXTENDED_PRICE_BUNDLE'
},
'Endertech_BundleExtended/js/price-bundle': {'priceBundle': 'SOURCE_TO_ORIGINAL_PRICE_BUNDLE'}
}
};
edited Jun 9 '16 at 11:42
answered Jun 9 '16 at 11:38
imelnychenkoimelnychenko
212
212
I tried this approach, but my file did not load at all.
– Noemi Quezada
Jun 9 '16 at 19:44
add a comment |
I tried this approach, but my file did not load at all.
– Noemi Quezada
Jun 9 '16 at 19:44
I tried this approach, but my file did not load at all.
– Noemi Quezada
Jun 9 '16 at 19:44
I tried this approach, but my file did not load at all.
– Noemi Quezada
Jun 9 '16 at 19:44
add a comment |
What I also found that worked was the following
In the module requirejs-config:
var config = {
map: {
'*': {
'mage/SwatchRenderer': 'Magento_Swatches/js/swatch-renderer',
'Magento_Swatches/js/swatch-renderer': 'MyVendor_MyModule/js/swatch-renderer'
}
}
};
And then I created a mymodule/view/frontend/web/js/swatch-renderer.js that contained:
define([
'jquery',
'jquery/ui',
'mage/SwatchRenderer',
], function ($) {
$.widget('myvendor.SwatchRenderer', $.mage.SwatchRenderer, {
_Rewind: function (controls) {
controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled');
controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled');
console.log('test');
},
});
return $.myvendor.SwatchRenderer;
});
add a comment |
What I also found that worked was the following
In the module requirejs-config:
var config = {
map: {
'*': {
'mage/SwatchRenderer': 'Magento_Swatches/js/swatch-renderer',
'Magento_Swatches/js/swatch-renderer': 'MyVendor_MyModule/js/swatch-renderer'
}
}
};
And then I created a mymodule/view/frontend/web/js/swatch-renderer.js that contained:
define([
'jquery',
'jquery/ui',
'mage/SwatchRenderer',
], function ($) {
$.widget('myvendor.SwatchRenderer', $.mage.SwatchRenderer, {
_Rewind: function (controls) {
controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled');
controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled');
console.log('test');
},
});
return $.myvendor.SwatchRenderer;
});
add a comment |
What I also found that worked was the following
In the module requirejs-config:
var config = {
map: {
'*': {
'mage/SwatchRenderer': 'Magento_Swatches/js/swatch-renderer',
'Magento_Swatches/js/swatch-renderer': 'MyVendor_MyModule/js/swatch-renderer'
}
}
};
And then I created a mymodule/view/frontend/web/js/swatch-renderer.js that contained:
define([
'jquery',
'jquery/ui',
'mage/SwatchRenderer',
], function ($) {
$.widget('myvendor.SwatchRenderer', $.mage.SwatchRenderer, {
_Rewind: function (controls) {
controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled');
controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled');
console.log('test');
},
});
return $.myvendor.SwatchRenderer;
});
What I also found that worked was the following
In the module requirejs-config:
var config = {
map: {
'*': {
'mage/SwatchRenderer': 'Magento_Swatches/js/swatch-renderer',
'Magento_Swatches/js/swatch-renderer': 'MyVendor_MyModule/js/swatch-renderer'
}
}
};
And then I created a mymodule/view/frontend/web/js/swatch-renderer.js that contained:
define([
'jquery',
'jquery/ui',
'mage/SwatchRenderer',
], function ($) {
$.widget('myvendor.SwatchRenderer', $.mage.SwatchRenderer, {
_Rewind: function (controls) {
controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled');
controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled');
console.log('test');
},
});
return $.myvendor.SwatchRenderer;
});
answered Sep 12 '16 at 13:05
KoenKoen
111
111
add a comment |
add a comment |
If your core js use widget then you also call that widget and return that widget variable in a mixin.
Bundle mixin you have to create requirejs-config.js
in your custom module at
Vendor/Extension/view/frontend/requirejs-config.js
put below code in appropriate js
requirejs-config.js
:
var config = {
config: {
mixins: {
'Magento_Bundle/js/price-bundle': {
'Vendor_Extension/js/price-bundle-mixin': true
}
}
},
};
price-bundle-mixin
:
define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox'
], function ($, _, mageTemplate, utils) {
'use strict';
return function (priceBundle) {
$.widget('mage.priceBundle', priceBundle, {
// function which you want to overwrite
});
// don't forget to add a function which is used by your
// functions, else it will show undefined function error
return $.mage.priceBundle;
};
});
add a comment |
If your core js use widget then you also call that widget and return that widget variable in a mixin.
Bundle mixin you have to create requirejs-config.js
in your custom module at
Vendor/Extension/view/frontend/requirejs-config.js
put below code in appropriate js
requirejs-config.js
:
var config = {
config: {
mixins: {
'Magento_Bundle/js/price-bundle': {
'Vendor_Extension/js/price-bundle-mixin': true
}
}
},
};
price-bundle-mixin
:
define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox'
], function ($, _, mageTemplate, utils) {
'use strict';
return function (priceBundle) {
$.widget('mage.priceBundle', priceBundle, {
// function which you want to overwrite
});
// don't forget to add a function which is used by your
// functions, else it will show undefined function error
return $.mage.priceBundle;
};
});
add a comment |
If your core js use widget then you also call that widget and return that widget variable in a mixin.
Bundle mixin you have to create requirejs-config.js
in your custom module at
Vendor/Extension/view/frontend/requirejs-config.js
put below code in appropriate js
requirejs-config.js
:
var config = {
config: {
mixins: {
'Magento_Bundle/js/price-bundle': {
'Vendor_Extension/js/price-bundle-mixin': true
}
}
},
};
price-bundle-mixin
:
define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox'
], function ($, _, mageTemplate, utils) {
'use strict';
return function (priceBundle) {
$.widget('mage.priceBundle', priceBundle, {
// function which you want to overwrite
});
// don't forget to add a function which is used by your
// functions, else it will show undefined function error
return $.mage.priceBundle;
};
});
If your core js use widget then you also call that widget and return that widget variable in a mixin.
Bundle mixin you have to create requirejs-config.js
in your custom module at
Vendor/Extension/view/frontend/requirejs-config.js
put below code in appropriate js
requirejs-config.js
:
var config = {
config: {
mixins: {
'Magento_Bundle/js/price-bundle': {
'Vendor_Extension/js/price-bundle-mixin': true
}
}
},
};
price-bundle-mixin
:
define([
'jquery',
'underscore',
'mage/template',
'priceUtils',
'priceBox'
], function ($, _, mageTemplate, utils) {
'use strict';
return function (priceBundle) {
$.widget('mage.priceBundle', priceBundle, {
// function which you want to overwrite
});
// don't forget to add a function which is used by your
// functions, else it will show undefined function error
return $.mage.priceBundle;
};
});
answered 6 mins ago
HimanshuHimanshu
965622
965622
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f118153%2fmagento-2-how-to-override-core-js-module-price-bundle-js%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
We may have architecture for this. Checking.
– benmarks♦
Jun 7 '16 at 16:06
2
Confirmed, we have JavaScript mixins which can do this. You'll get a response soon.
– benmarks♦
Jun 8 '16 at 15:34
@benmarks thank you so much for looking into my issue, I had also thought about JavaScript mixins, but the first time I attempted it I was having issues accessing some of the
$.mage.priceBundle
parameters and methods.– Noemi Quezada
Jun 8 '16 at 21:26
@NoemiQuezada Please mark the correct answer
– Stevie G
Jan 13 '17 at 15:00
Hi @NoemiQuezada have you got solution for it. please share the piece of code if you find any solution regrading it
– Himanshu
56 mins ago