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

Multiple prepareStoreView calls overwrites existing store-view config incorrectly #3655

Closed
2 of 5 tasks
cewald opened this issue Sep 30, 2019 · 3 comments
Closed
2 of 5 tasks
Labels
bug Bug reports P2: Important Priority mark - still high ;)
Milestone

Comments

@cewald
Copy link
Contributor

cewald commented Sep 30, 2019

Current behavior

If the prepareStoreView method is called multiple times after another, it overwrites the existing config with a plain store object if using extend to extend the current store.
After the first call, the extend property of the StoreView object is gone and then the getExtendedStoreviewConfig method merges wrong configs on second run.

This happens for example since in the new search adapter core/lib/search/adapter/api/searchAdapter.ts:42 when it calls prepareStoreView method the second time.

It seems that it is caused by delete storeView.extend in the getExtendedStoreviewConfig method. If I remove this line, everything works as expected.

Expected behavior

Show the correctly extended store view config, no matter how often it is prepared.

Steps to reproduce the issue

  • Enable multi-store environment with using extend on a store-view
  • Log the store-view result of prepareStoreView method
  • Load the store which is using the extend config
  • On first method call it's correctly extended (Client-Log)
  • On the second, e.g. called by core/lib/search/adapter/api/searchAdapter.ts, it's a plain one without the extend config value so it can't extend the configs correctly anymore

Repository

develop:latest 8e36289

Can you handle fixing this bug by yourself?

  • YES (I try)
  • NO

Which Release Cycle state this refers to? Info for developer.

Pick one option.

  • This is a bug report for test version on https://test.storefrontcloud.io - In this case Developer should create branch from develop branch and create Pull Request 2. Feature / Improvement back to develop.
  • This is a bug report for current Release Candidate version on https://next.storefrontcloud.io - In this case Developer should create branch from release branch and create Pull Request 3. Stabilisation fix back to release.
  • This is a bug report for current Stable version on https://demo.storefrontcloud.io and should be placed in next stable version hotfix - In this case Developer should create branch from hotfix or master branch and create Pull Request 4. Hotfix back to hotfix.

Environment details

  • Browser: Chrome
  • OS: OSX
  • Node: 10 LTS
  • Code Version: develop:latest
@cewald cewald added the bug Bug reports label Sep 30, 2019
@cewald
Copy link
Contributor Author

cewald commented Sep 30, 2019

So, if I remove the storeView.extend code in getExtendedStoreviewConfig it is working:

function getExtendedStoreviewConfig (storeView: StoreView): StoreView {
  if (storeView.extend) {
    const originalParent = storeView.extend

    if (!config.storeViews[originalParent]) {
      Logger.error(`Storeview "${storeView.extend}" doesn't exist!`)()
    } else {
      storeView = merge(
        {},
        getExtendedStoreviewConfig(config.storeViews[originalParent]),
        storeView
      )
    }
  }

  return storeView
}

I don't see the need of this two lines anyway when we are using lodash-es/merge in this order.
Should I open a PR without this lines or are there any doubts?

@pkarw
Copy link
Collaborator

pkarw commented Sep 30, 2019

hi, @cewald thanks for that one! @andrzejewsky was fixing pretty much similar issue; @andrzejewsky please look at this one

@pkarw pkarw added the P2: Important Priority mark - still high ;) label Sep 30, 2019
@pkarw pkarw added this to the 1.11.0-rc.1 milestone Sep 30, 2019
@andrzejewsky
Copy link
Contributor

@cewald yeah you are right, it works without that line, thanks! (Sorry I was faster with the PR 😃 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports P2: Important Priority mark - still high ;)
Projects
None yet
Development

No branches or pull requests

3 participants