Skip to content

Commit

Permalink
Merge pull request #2169 from pkarw/develop
Browse files Browse the repository at this point in the history
Fix to #2116
  • Loading branch information
pkarw authored Jan 11, 2019
2 parents 4da8bcf + 8e19f08 commit 9281230
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/modules/catalog/store/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ const actions: ActionTree<ProductState, RootState> = {
* Search products by specific field
* @param {Object} options
*/
single (context, { options, setCurrentProduct = true, selectDefaultVariant = true, key = 'sku', skipCache = false }) {
single (context, { options, setCurrentProduct = true, selectDefaultVariant = true, assignDefaultVariant = false, key = 'sku', skipCache = false }) {
if (!options[key]) {
throw Error('Please provide the search key ' + key + ' for product/single action!')
}
Expand Down Expand Up @@ -409,7 +409,10 @@ const actions: ActionTree<ProductState, RootState> = {
if (prod.type_id === 'configurable' && hasConfigurableChildren) {
// set first available configuration
// todo: probably a good idea is to change this [0] to specific id
configureProductAsync(context, { product: prod, configuration: { sku: options.childSku }, selectDefaultVariant: selectDefaultVariant, setProductErorrs: true })
const selectedVariant = configureProductAsync(context, { product: prod, configuration: { sku: options.childSku }, selectDefaultVariant: selectDefaultVariant, setProductErorrs: true })
if (selectedVariant && assignDefaultVariant) {
prod = Object.assign(prod, selectedVariant)
}
} else if (!skipCache || ('simple' === prod.type_id || 'downloadable' === prod.type_id)) {
if (setCurrentProduct) context.dispatch('setCurrent', prod)
}
Expand Down

0 comments on commit 9281230

Please sign in to comment.