Skip to content

Module Catalog URL Rewrite: fix issue with product URL Rewrites re-generation after changing product URL Key for product with existing url_path attribute value #18566

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

Conversation

oleksii-lisovyi
Copy link

Hiving saved product attribute URL Path value causes broken Product URL Rewrites regeneration after changing product URL key.

Description (*)

If there is a product with set URL Path attribute value, product URL Rewrites can't be re-generated clearly after changing product URL Key from Admin panel.
For example, after migrating from Magento 1, there are a lot of values for product attribute URL Path.

Fixed Issues (if relevant)

#5929: Saving Product does not update URL rewrite in Magento 2.1.0.

Causes Issues

#18532: Module Catalog: product "Save and Duplicate" causes getting infinite loop.

Manual testing scenarios (*)

  1. Set attribute URL Path value for any product.
    1.1. For example, execute following SQL query:
SET @catalogProductEntityTypeId = (SELECT `entity_type_id`
                                   FROM `eav_entity_type`
                                   WHERE entity_type_code = 'catalog_product');

SET @productUrlPathAttributeId = (SELECT `attribute_id`
                                  FROM `eav_attribute`
                                  WHERE `attribute_code` = 'url_path'
                                    AND entity_type_id = @catalogProductEntityTypeId);

SET @productUrlKeyAttributeId = (SELECT `attribute_id`
                                 FROM `eav_attribute`
                                 WHERE `attribute_code` = 'url_key'
                                   AND `entity_type_id` = @catalogProductEntityTypeId);

SET @storeId = 1; -- change Store ID if it's required

SET @testProductId = 1; -- change Product ID if it's required

SET @existingProductUrlKey = (SELECT `value`
                              FROM `catalog_product_entity_varchar`
                              WHERE `entity_id` = @testProductId
                                AND `attribute_id` = @productUrlKeyAttributeId); -- any value could be there

INSERT INTO `catalog_product_entity_varchar` (`attribute_id`, `store_id`, `entity_id`, `value`)
    VALUES (@productUrlPathAttributeId, @storeId, @testProductId, @existingProductUrlKey);
  1. Go to Admin panel -> Catalog -> Inventory -> Products.
  2. Find and open testable product.
  3. Change URL Key field value.
  4. Save product.
  5. Go to product page on frontend by new URL Key.

Expected result

Product is available by the new URL Key.

Actual result

Product is not available by the new URL Key, but available by the previous one.

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)

…neration after changing product URL Key for product with existing url_path attribute value
@magento-engcom-team
Copy link
Contributor

Hi @oleksii-lisovyi. 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 $VERSION instance - deploy vanilla Magento instance

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

@magento-engcom-team
Copy link
Contributor

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

@hostep
Copy link
Contributor

hostep commented Oct 15, 2018

Just a remark, might be wrong about this, but I've some experience with this problem:
Since the url_path attribute is never filled in if you manually create a product in Magento 2 using the backend, and it is only used in code for generating url rewrites when that attribute actually does has a value (which it only seems to get by migrating M1 to M2). Shouldn't we just remove the url_path attribute all together from Magento source code and from the database?
In that case this fix is not needed I believe?

@oleksii-lisovyi
Copy link
Author

@hostep, removing such a big part of functionality is backward incompatible change, so it will not happen in the nearest feature.

@magento-engcom-team magento-engcom-team merged commit 9b0586e into magento:2.2-develop Oct 19, 2018
magento-engcom-team pushed a commit that referenced this pull request Oct 19, 2018
…ewrites re-generation after changing product URL Key for product with existing url_path attribute value #18566
@magento-engcom-team
Copy link
Contributor

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

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

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.

4 participants