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

URL Rewrite destroyed #26940

Closed
bernd-reindl opened this issue Feb 20, 2020 · 17 comments
Closed

URL Rewrite destroyed #26940

bernd-reindl opened this issue Feb 20, 2020 · 17 comments
Labels
Issue: ready for confirmation Reported on 2.3.4 Indicates original Magento version for the Issue report. stale issue

Comments

@bernd-reindl
Copy link

bernd-reindl commented Feb 20, 2020

Preconditions (*)

  1. Magento 2.3.4

Steps to reproduce (*)

  1. Setup a multi website (not store) environment. (E.G. Website 1 = DE; Website 2 = EN)
  2. Add a categories and translate the url path (E.G. global:Kategorie 1 (kategorie-1); website 2:Category 1 (category-1)
  3. Add a product to the category and assign only to website 1 (Do not assign the product to website 2)
  4. Check the URL rewrites.
  5. Go to the category and change the path of the category in website 2 (E.G. category-en)
  6. Check the URL rewrites again

Expected result (*)

  1. The paths for product containing the categories should be german in website 1

Actual result (*)

  1. The paths for product containing the categories are english in website 1

Description

When a category path was changed in website > 1 and a product is not assignt to this website, the paths for this product will be corrupted in the default website (1)

@m2-assistant
Copy link

m2-assistant bot commented Feb 20, 2020

Hi @bernd-reindl. 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.

@bernd-reindl do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Feb 20, 2020
@magento-deployment-service
Copy link

Hi @m2-assistant[bot] Here is your new Magento Instance: https://i-26940-2-4-develop.magento-testing-service.engineering
Admin access: https://i-26940-2-4-develop.magento-testing-service.engineering/admin_afb8
Login: 11924ee6, Password: eeb3982b98bf

@bernd-reindl
Copy link
Author

I can confirm this is reproduceable in vanilla Magento (2.4-dev)

url_rewrite
category-website 1
category-website 2

@GDauer GDauer self-assigned this Feb 21, 2020
@m2-assistant
Copy link

m2-assistant bot commented Feb 21, 2020

Hi @GDauer. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!


@bernd-reindl
Copy link
Author

Issue: Clear Description
Reproduced on 2.4.x

@GDauer
Copy link
Contributor

GDauer commented Feb 21, 2020

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

@magento-engcom-team
Copy link
Contributor

Hi @GDauer. Thank you for your request. I'm working on Magento 2.4-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @GDauer, here is your Magento instance.
Admin access: https://i-26940-2-4-develop.instances.magento-community.engineering/admin_1e8c
Login: 0e7a6a93 Password: 7030602188fd
Instance will be terminated in up to 3 hours.

@GDauer
Copy link
Contributor

GDauer commented Feb 22, 2020

@magento give me 2.3.4 instance

@magento-engcom-team
Copy link
Contributor

Hi @GDauer. Thank you for your request. I'm working on Magento 2.3.4 instance for you

@magento-engcom-team
Copy link
Contributor

Hi @GDauer, here is your Magento instance.
Admin access: https://i-26940-2-3-4.instances.magento-community.engineering/admin_34bb
Login: aaaf757c Password: 637532920abf
Instance will be terminated in up to 3 hours.

@GDauer
Copy link
Contributor

GDauer commented Feb 22, 2020

Hi @bernd-reindl i'm trying to work on your issue but i could not reproduce it. Can you give more information, maybe a video?

@GDauer GDauer added Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Progress: needs update labels Feb 22, 2020
@bernd-reindl
Copy link
Author

i already have reproduced it in https://i-26940-2-4-develop.magento-testing-service.engineering/admin_afb8

See my screenshots above.

@bernd-reindl
Copy link
Author

https://drive.google.com/file/d/17pbMZ6p_E9ok4HwfVlAv69z8eSS5FAOD/view?usp=sharing

Create 2 Websites. First DE, Second EN
Add a category but don´t translate for EN for now
Add a product and add it only to DE
Check the URL rewirtes for product in website DE
Change the path of category for website EN
Check the URL rewrites again

Expected result: URL should not changed, because product is only in website DE
Actual result: The URL has changed to category-1/produkt-1.html in website DE

If the product is assigned to website DE and EN, the URL for DE is kategorie-1/produkt-1.html and for EN category-1/product-1.html.
This only happens if the product is not assigned to all existing websites

Hope this helps.

@bernd-reindl
Copy link
Author

Hi @GDauer,

i have found a solution.

in Magento\Catalog\Model\ResourceModel\Product
in function getCategoryCollection()
the store ID from product is not set for category collection. So the returned categoies return url_key and url_path from selected store in the backend view. Not the store for whitch the url rewrite is generated.

So i have changed the code like this:

public function getCategoryCollection($product)
    {
        /** @var Category\Collection $collection */
        $collection = $this->_categoryCollectionFactory->create();
		if($product->getStoreId()) {
			$collection->setStoreId($product->getStoreId());
		}
        $collection->joinField(
            'product_id',
            'catalog_category_product',
            'product_id',
            'category_id = entity_id',
            null
        )->addFieldToFilter(
            'product_id',
            (int)$product->getEntityId()
        );
        return $collection;
    }

The second problem is in Magento\CatalogUrlRewrite\Model\Product\AnchorUrlRewriteGenerator
in function generate()
the store ID isn't set when get the category in row 70. So i have changed

$anchorCategory = $this->categoryRepository->get($anchorCategoryId);
to
$anchorCategory = $this->categoryRepository->get($anchorCategoryId, $storeId);

Now it works like expected.

@hostep
Copy link
Contributor

hostep commented Mar 21, 2020

@bernd-reindl: that last fix you mentioned is finally being added to the Magento core, it has been a bug since Magento2 got released, but they finally accepted the fix in #26784
This fix will be included in Magento 2.4.0, but hopefully as well in Magento 2.3.5 or 2.3.6, but I'm not sure about that...

@ghost ghost added Issue: ready for confirmation and removed Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Oct 20, 2020
@magento-engcom-team magento-engcom-team added the Reported on 2.3.4 Indicates original Magento version for the Issue report. label Nov 13, 2020
@stale
Copy link

stale bot commented Jan 29, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

@stale stale bot added the stale issue label Jan 29, 2021
@stale stale bot closed this as completed Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: ready for confirmation Reported on 2.3.4 Indicates original Magento version for the Issue report. stale issue
Projects
None yet
Development

No branches or pull requests

5 participants