-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-52974: Configurable product options not saved when editing - …
…for mainline
- Loading branch information
1 parent
2275b89
commit 97390b3
Showing
8 changed files
with
108 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 41 additions & 18 deletions
59
app/code/Magento/Swatches/view/frontend/web/js/configurable-customer-data.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,51 @@ | ||
require([ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define([ | ||
'jquery', | ||
'Magento_ConfigurableProduct/js/options-updater' | ||
'Magento_ConfigurableProduct/js/options-updater', | ||
'jquery/ui' | ||
], function ($, Updater) { | ||
'use strict'; | ||
|
||
var selectors = { | ||
formSelector: '#product_addtocart_form', | ||
swatchSelector: '.swatch-opt' | ||
$.widget('mage.selectSwatch', { | ||
options: { | ||
swatchOptions: null, | ||
selectors: { | ||
formSelector: '#product_addtocart_form', | ||
swatchSelector: '.swatch-opt' | ||
}, | ||
swatchWidgetName: 'mageSwatchRenderer', | ||
widgetInitEvent: 'swatch.initialized', | ||
clickEventName: 'emulateClick' | ||
}, | ||
swatchWidgetName = 'mageSwatchRenderer', | ||
widgetInitEvent = 'swatch.initialized', | ||
|
||
/** | ||
* Sets all configurable swatch attribute's selected values | ||
*/ | ||
updateSwatchOptions = function () { | ||
var swatchWidget = $(selectors.swatchSelector).data(swatchWidgetName); | ||
/** | ||
* Widget initialisation. | ||
* Configurable product options updater listens to selected swatch options | ||
*/ | ||
_init: function () { | ||
var updater; | ||
|
||
if (!swatchWidget || !swatchWidget._EmulateSelectedByAttributeId) { | ||
return; | ||
updater = new Updater(this.options.widgetInitEvent, this.selectDefaultSwatchOptions.bind(this)); | ||
updater.listen(); | ||
}, | ||
|
||
/** | ||
* Sets default configurable swatch attribute's selected | ||
*/ | ||
selectDefaultSwatchOptions: function () { | ||
var swatchWidget = $(this.options.selectors.swatchSelector).data(this.options.swatchWidgetName); | ||
|
||
if (!swatchWidget || !swatchWidget._EmulateSelectedByAttributeId) { | ||
return; | ||
} | ||
swatchWidget._EmulateSelectedByAttributeId( | ||
this.options.swatchOptions.defaultValues, this.options.clickEventName | ||
); | ||
} | ||
swatchWidget._EmulateSelectedByAttributeId(this.productOptions); | ||
}, | ||
updater = new Updater(widgetInitEvent, updateSwatchOptions); | ||
}); | ||
|
||
updater.listen(); | ||
return $.mage.selectSwatch; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters