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

Fixed #20282 Module Catalog Url Rewrite: Permanent Redirect for old URL is missed when product was imported #20344

Merged

Conversation

verma-ankur
Copy link
Member

@verma-ankur verma-ankur commented Jan 16, 2019

Fixed ##20282 Module Catalog Url Rewrite: Permanent Redirect for old URL is missed when product was imported

You have to add one more column in you csv file named 'save_rewrites_history' set it to 1 or 0 based on your requirement. Set it to 1 if you want permanent redirect for old URL of your product.

Preconditions (*)

Magento 2.2.7

Steps to reproduce (*)

Export some visible product via System-> Data Transfer-> Export.
Change 'url-key' for this product in CSV file.
Import this product via System-> Data Transfer-> Import.

Expected result (*)

When you try to open the changed product by the old URL key you are redirected to the new URL.

Actual result (*)

When you try to open the changed product by the old URL key you receive 404-page.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

Fixed magento#20282 Module Catalog Url Rewrite: Permanent Redirect for old URL is missed when product was imported
@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Jan 16, 2019

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team
Copy link
Contributor

Hi @ankur-cedcoss. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@aleron75
Copy link
Contributor

Hello,
I may be wrong but, as pointed here, this doesn't seem to be an issue.

Choosing whether to generate a redirect is optional in the Admin Panel, forcing it in import would not be consistent.

Let me know.

@verma-ankur
Copy link
Member Author

@aleron75

The reference you provided is to handle every product URL rewrite manually.
And the solution I provided is to handle the URL rewrite automatically.

And my solution is not forcing to generate the URL rewrite.
It is still optional. If you want to generate the URL write for old URL then you have to pass this information in your import csv file.
For it you have to increase a column in your csv file named 'save_rewrites_history'. and you can pass value 1 or 0 for this column.
If you want to generate the rewrite set the 'save_rewrites_history' field value to 1.
other wise either set 0 or do not provide a value at all.

@rogyar rogyar self-assigned this Jan 18, 2019
@aleron75
Copy link
Contributor

Hello @ankur-cedcoss, thanks for the clarification.

@magento-engcom-team
Copy link
Contributor

Hi @aleron75, thank you for the review.
ENGCOM-3925 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

@ankur-cedcoss thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@ghost
Copy link

ghost commented Jan 29, 2019

Hi @ankur-cedcoss, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

magento-engcom-team pushed a commit that referenced this pull request Jan 29, 2019
…ect for old URL is missed when product was imported #20344
@magento-engcom-team
Copy link
Contributor

Hi @ankur-cedcoss. Thank you for your contribution.
We will aim to release these changes as part of 2.3.1.
Please check the release notes for final confirmation.

@magento-engcom-team
Copy link
Contributor

Hi @ankur-cedcoss. Thank you for your contribution.
We will aim to release these changes as part of 2.3.1.
Please check the release notes for final confirmation.

@stijnkuppens
Copy link

stijnkuppens commented Mar 17, 2021

There is still a bug in scenario. In file:
vendor/magento/module-catalog-url-rewrite/Observer/AfterImportDataObserver.php:currentUrlRewritesRegenerate()
around line 487

$urlRewrites = $url + $urlRewrites;

has to be:

$urlRewrites = array_merge($url,$urlRewrites);

Otherwise the new created url rewrites will not be saved.
The '+' will preserve the array keys without doing overrides. In this case we don't have specific array keys, thus the new rewrites are ignored and not added in the resulting array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants