Skip to content
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

Cart Configurable item pulled from magento loaded as Simple #2116

Closed
valeriish opened this issue Dec 27, 2018 · 10 comments
Closed

Cart Configurable item pulled from magento loaded as Simple #2116

valeriish opened this issue Dec 27, 2018 · 10 comments
Assignees

Comments

@valeriish
Copy link
Contributor

valeriish commented Dec 27, 2018

Steps to reproduce the issue

  1. Login-in as customer
  2. Add configurable product to cart
  3. Examine minicart, new item have parent name, image, url, type = configurable
  4. Login-out and login-in

Expected behavior

Cart item have type 'configurable'.
Name, image, etc are getting from assigned parent product

Current behavior

Cart item have type 'simple'.
Cart item displays name, image, etc of 'not visible individually' current simple product

Can you handle fixing this bug by yourself?

Yes
Issue: cart item is loading by serverItem.sku after ServerPull for configurable item

@pkarw
Copy link
Collaborator

pkarw commented Dec 27, 2018

Thanks, how would You like to fix this one? Please feel free to report a Pull Request

@valeriish
Copy link
Contributor Author

valeriish commented Dec 29, 2018

After testing i found out that
rootStore.dispatch('product/single', { options: { sku: .. , childSku: ... }}) doesn't correct populate configurable item
For example: if i have 2 configurable item with same parent and different attribute value, afterServerPull return merged item with qty = 2 and only first attribute vaue
Workaround to fix it - add
if (actionOtions['childSku']) { rootStore.dispatch('product/configure', { product: product, configuration: { sku: actionOtions['childSku'] }, selectDefaultVariant: false, fallbackToDefaultWhenNoAvailable: false }).then((selectedVariant) => { resolve({ product: Object.assign({}, product, selectedVariant), serverItem: serverItem }) }) }
in servercartAfterPulled

but maybe better is fix 'product/single' method?

@pkarw
Copy link
Collaborator

pkarw commented Dec 29, 2018

Correct. Method “single” is not using the “childSku” at all as far as I remember (not being in front of my computer to check it right now ...) I think it makes sense to fix it at the origin - in the single action. However your fix is also just fine.

By this chance you might want to add code comments on how to use the action parameters correctly wdyt?

@valeriish
Copy link
Contributor Author

This is workaround, i tried to update 'product/single' method, but it's affect on other logic.

@pkarw
Copy link
Collaborator

pkarw commented Dec 29, 2018

Thanks I’ll take a look at it later on I believe that we just should add a check if there is options.childSku set and pass this argument to configure some way but I must take a look at it

Your desired behavior is that call to single action will load parent product pointed out by ”sku” and them configure it to ”childSku” variant. Correct?

@valeriish
Copy link
Contributor Author

Yes, you're correct

@pkarw pkarw self-assigned this Dec 31, 2018
@pkarw pkarw added this to the 1.7 | Performance milestone Dec 31, 2018
@pkarw
Copy link
Collaborator

pkarw commented Jan 11, 2019

@pkarw
Copy link
Collaborator

pkarw commented Jan 11, 2019

@pkarw
Copy link
Collaborator

pkarw commented Jan 11, 2019

OK I found the problem and added an option assignDefaultVariant to have this side effect of the single - I mean the configured product as a result.

Now its:
single (context, { options, setCurrentProduct = true, selectDefaultVariant = true, assignDefaultVariant = false, key = 'sku', skipCache = false })

and in Your case You should call sth like:

dispatch('product/single', {
          options: actionOptions,
          assignDefaultVariant: true
        })

pkarw added a commit that referenced this issue Jan 11, 2019
valeriish pushed a commit to valeriish/vue-storefront that referenced this issue Jan 14, 2019
- Update method after changes in product 'single' action
@valeriish
Copy link
Contributor Author

valeriish commented Jan 14, 2019

Thank you!

servercartAfterPulled method was updated please review

@pkarw pkarw closed this as completed Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants