-
Notifications
You must be signed in to change notification settings - Fork 2.1k
add redirection in component for simple product related to configurable product #4426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9b2c63f
5b89b8e
9b427c2
41c791b
68b0a4b
fc56390
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ import EventBus from '@vue-storefront/core/compatibility/plugins/event-bus' | |
| import { StorageManager } from '@vue-storefront/core/lib/storage-manager' | ||
| import { quickSearchByQuery } from '@vue-storefront/core/lib/search' | ||
| import { formatProductLink } from 'core/modules/url/helpers' | ||
| import { checkParentRedirection } from '@vue-storefront/core/modules/catalog/events' | ||
|
|
||
| const PRODUCT_REENTER_TIMEOUT = 20000 | ||
|
|
||
|
|
@@ -640,7 +641,12 @@ const actions: ActionTree<ProductState, RootState> = { | |
| throw new Error(`Product query returned empty result product status = ${product.status}`) | ||
| } | ||
| if (product.visibility === 1) { // not visible individually (https://magento.stackexchange.com/questions/171584/magento-2-table-name-for-product-visibility) | ||
| throw new Error(`Product query returned empty result product visibility = ${product.visibility}`) | ||
| if (config.products.preventConfigurableChildrenDirectAccess) { | ||
| const parentProduct = await dispatch('findConfigurableParent', { product }) | ||
| checkParentRedirection(product, parentProduct) | ||
| } else { | ||
| throw new Error(`Product query returned empty result product visibility = ${product.visibility}`) | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The redirect itself seems to work fine. However, I'm thinking whether it would be good to decouple this setting from the visibility configuration. Having them uncoupled would allow showing a child product on category page, but the link would take you to the parent product. But this is just my thought. I'm not sure how may shops would actually find this useful.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This action is called only on PDP. So with that you can still show simple product on category page and after going on PDP you will be redirected.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also coupled it with visibility because we should check this only when its needed. Right now we are making request for every simple product. With this change it will be done only when you want to get on PDP where simple product shouldn't be visible |
||
| } | ||
|
|
||
| await dispatch('loadProductAttributes', { product }) | ||
|
|
@@ -651,12 +657,6 @@ const actions: ActionTree<ProductState, RootState> = { | |
| syncPromises.push(variantsFilter) | ||
| syncPromises.push(gallerySetup) | ||
| } | ||
| if (config.products.preventConfigurableChildrenDirectAccess) { | ||
| const parentChecker = dispatch('checkConfigurableParent', { product }) | ||
| if (isServer) { | ||
| syncPromises.push(parentChecker) | ||
| } | ||
| } | ||
| await Promise.all(syncPromises) | ||
| await EventBus.$emitFilter('product-after-load', { store: rootStore, route: route }) | ||
| return product | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.