Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

[Bug]: Mutated value for config.products.omitVariantFields #496

Open
2 of 3 tasks
didkan opened this issue Oct 13, 2021 · 0 comments
Open
2 of 3 tasks

[Bug]: Mutated value for config.products.omitVariantFields #496

didkan opened this issue Oct 13, 2021 · 0 comments
Labels
bug Bug reports

Comments

@didkan
Copy link

didkan commented Oct 13, 2021

Describe the Bug

In this commit:
55040a1
a hardcoded array was moved into config.
The problem is that the following push() will then mutate the original array config.products.omitVariantFields for every consecutive call, so that image is omitted even when it should not.

This means that configured products will not have the expected image property value in e.g. Product.vue page.

If we are going to use push()here we need to operate on a copy of the array and not the actual config array.
Or we can also use array spread operator to return the correct result.

Solution 1:
Make a copy of the config array.

const fieldsToOmit = config.products.omitVariantFields.slice()

Solution 2:
Create return value via spread operator

const fieldsToOmit = [...config.products.omitVariantFields, !hasImage ? 'image': null]

Current behavior

If any previously loaded product variant does not have a base image in Magento, then image will be omitted form all consecutive product variants loaded/configured.
When loading the product page with a configurable product, getCurrentProduct.image does not have the expected image (the image of the currently selected variant)

Expected behavior

When loading the product page with a configurable product, getCurrentProduct.image should have the value from the currently selected variant (simple product)

Steps to reproduce

No response

What version of Vue Storefront are you using?

1.12.3

What version of Node.js are you using?

14.17.6

What browser (and version) are you using?

Chrome 94.0.4606.81 (Official Build) (arm64)

What operating system (and version) are you using?

macOS Big Sur

Relevant log output

No response

Able to fix / change the documentation?

  • Yes
  • No

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug reports
Projects
None yet
Development

No branches or pull requests

1 participant