Skip to content

Commit 4787517

Browse files
add check if attribute value is possible to be set
* a none existing value would be set and the dropdown would show an empty value (not the please select message)
1 parent 9fc6972 commit 4787517

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@ define([
139139
});
140140

141141
$.each(queryParams, $.proxy(function (key, value) {
142-
this.options.values[key] = value;
142+
if (this.options.spConfig.attributes[key] !== undefined
143+
&& this.options.spConfig.attributes[key].options.find(function(element) {
144+
return element.id===value;
145+
})) {
146+
this.options.values[key] = value;
147+
}
143148
}, this));
144149
},
145150

@@ -155,7 +160,13 @@ define([
155160

156161
if (element.value) {
157162
attributeId = element.id.replace(/[a-z]*/, '');
158-
this.options.values[attributeId] = element.value;
163+
164+
if (this.options.spConfig.attributes[attributeId] !== undefined
165+
&& this.options.spConfig.attributes[attributeId].options.find(function(optionElement) {
166+
return optionElement.id===element.value;
167+
})) {
168+
this.options.values[attributeId] = element.value;
169+
}
159170
}
160171
}, this));
161172
},

0 commit comments

Comments
 (0)