Skip to content

Category API should support save_rewrites_history for consistency reasons #29174

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

Closed
amenk opened this issue Jul 16, 2020 · 4 comments · Fixed by #29205
Closed

Category API should support save_rewrites_history for consistency reasons #29174

amenk opened this issue Jul 16, 2020 · 4 comments · Fixed by #29205
Assignees
Labels
feature request Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.

Comments

@amenk
Copy link
Contributor

amenk commented Jul 16, 2020

Description

When updating category URL keys via REST API there is no possibility to automatically create 301 redirects for the old URL key to the new one.

For products this is possible

Expected behavior (*)

contents of category-rename.json

 {"category":{"name":"new name","is_active":1,"parentId":2366,"custom_attributes":[{"attribute_code":"url_key","value":"new name"},{"attribute_code":"save_rewrites_history","value":1}]}}

When making a API call like

 curl -k -X PUT $BASEURL/rest/V1/categories/1295  -H 'Content-Type: application/json' -H "Authorization: Bearer $BEARER" -d @category-rename.json

I expect that a new entry is created a the end of url_rewrite database table with the old url_key redirecting to the new category.
Instead, after the API call, I cannot find the URL key anywhere in the url_rewrite table.

Benefits

There are shops which are managed by PIM systems via API. Here it is important for SEO reasons, to allow renaming the URL key without loosing old links.

Additional information

There was already a pull request implementing something similar, but without the option to not create rewrites.
#18408

The save_rewrites_history is supported for products. So for consistency this should also be possible for categories.

Maybe I can be implemented similarly to \Magento\CatalogUrlRewrite\Plugin\Webapi\Controller\Rest\InputParamsResolver::afterResolve

@m2-assistant
Copy link

m2-assistant bot commented Jul 16, 2020

Hi @amenk. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

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

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Jul 16, 2020
@magento-engcom-team magento-engcom-team added Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Jul 16, 2020
@VladimirZaets VladimirZaets added Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. Priority: P2 A defect with this priority could have functionality issues which are not to expectations. and removed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. labels Jul 17, 2020
amenk added a commit to iMi-digital/magento2 that referenced this issue Jul 20, 2020
@ghost ghost assigned amenk Jul 20, 2020
@amenk
Copy link
Contributor Author

amenk commented Jul 20, 2020

This is WIP.
Problem is that it doesn't work the same as with products as the flag we set gets lost in

\Magento\Catalog\Model\CategoryRepository::save

amenk added a commit to iMi-digital/magento2 that referenced this issue Jul 20, 2020
* Support save_rewrites_history in save
@amenk
Copy link
Contributor Author

amenk commented Jul 20, 2020

I found a workaround but I am not happy about it iMi-digital@00176f5

Does anybody have a better idea?

amenk added a commit to iMi-digital/magento2 that referenced this issue Jul 21, 2020
amenk added a commit to iMi-digital/magento2 that referenced this issue Jul 21, 2020
amenk added a commit to iMi-digital/magento2 that referenced this issue Jul 21, 2020
amenk added a commit to iMi-digital/magento2 that referenced this issue Jul 25, 2020
amenk added a commit to iMi-digital/magento2 that referenced this issue Jul 25, 2020
amenk added a commit to iMi-digital/magento2 that referenced this issue Jul 25, 2020
amenk added a commit to iMi-digital/magento2 that referenced this issue Jul 25, 2020
@m2-community-project m2-community-project bot added Progress: PR Created Indicates that Pull Request has been created to fix issue and removed Progress: PR in progress Progress: PR Created Indicates that Pull Request has been created to fix issue labels Sep 24, 2020
@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Sep 30, 2020
@m2-community-project m2-community-project bot added Progress: done and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Sep 30, 2020
magento-engcom-team added a commit that referenced this issue Sep 30, 2020
…29205

 - Merge Pull Request #29205 from iMi-digital/magento2:feature/29174-save-rewrites-for-categories
 - Merged commits:
   1. 5307bad
   2. 00176f5
   3. 4c99f0d
   4. f0ba72a
   5. 0f983b2
   6. 7f380b6
   7. 3361e72
   8. 79c54ae
   9. 99da072
   10. f61a27a
   11. 25111f0
   12. c7822ff
   13. df69e82
   14. 6fde4ba
   15. 9f81b49
   16. 9583212
   17. 1ad4482
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants