Also populate the storesCache when importing product only on storevie… #21094
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…w(s) level, previously the storesCache was only populated for products imported on global level. This causes problems with the correct url rewrites to be generated.
Description (*)
This was discovered by accident while debugging another problem, but it was an easy fix, hence the PR.
When importing a product with a new url key, you can add a flag
save_rewrites_history
with which you can indicate that you want to create a permanent redirect (301 http status code) from the old url key to the new one in theurl_rewrite
table.Previously, this only worked when importing a product on global level.
If you only want to change the
url_key
on storeview level, without importing the product on global level, this didn't work.This happens because when trying to find the old url rewrites associated with this product, it uses an internal
storesCache
which contains the storeview id's of the product(s) which you are importing, see here.This
storesCache
variable is only getting set when importing a product on global level, see here, but not when importing it only on storeview level, see here.This PR fixes this.
Fixed Issues (if relevant)
None found
Manual testing scenarios (*)
2.3-develop
, you need a very recent version, because support for thesave_rewrites_history
flag only got added recently.en_gb
anden_us
as storeview codes.Test1
,Test2
, and translate the url key on storeview level, but make sure to deselect theCreate Permanent Redirect for old URL
checkbox. In the end, the entries in yoururl_rewrite
table should look something like this:Now prepare two csv files to import:
In the backend, go to System > Data Transfer > Import
Use
Entity Type
=>Products
,Import Behavior
=>Add/Update
and leave the rest as isNow first import the first csv file, and then start from 5. again and import the second csv file
Check the
url_rewrite
table, without this PR it contains only 301 redirects for the Test1 product, but not for the Test2 product:With this PR, it will also have 301 redirects for the Test2 product.
Contribution checklist (*)