-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Wrong parent category url_key in URL #4112
Comments
internal issue MAGETWO-53443 |
Issue is not reproducible on 2.0.4, 2.0.7 and 2.1 with following combinations:
Please verify that parent category (german-parent-category) in your instance has url-key value overriden on store view level. Please provide more details on the category entities values on different store views. |
Hi @rganin Thank you for looking into this issue. All german url-keys are defined on default level (store view: all). The french url-keys are defined in the french store view. (In other words, no german url-keys are defined and/or overriden in the german store view). |
also, just to clarify, we are using this combination: 1 website (default), 2 store views (german (sort order 0) & french (sort order 1)). |
@bh-ref thanks for clarification, I will resume the investigation. |
@bh-ref still cannot reproduce the issue on 2.0.4. Sorry for the silly question but do you have url-key for french store view on parent category? Or do you have some url-related extensions or customizations? |
We have a similar problem. Category configuration: Product configuration: The url rewrite will be created after saving the product, but the category path is not store specific. We are using v2.0.6 and have traced down the problem. Inside app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php:80 the product categories are fetched, but not store specific. Later on it calls generateForSpecificStoreView() and passes the storeId, but the storeId is never used for calculating the category url path inside the following method: getUrlPathWithSuffix (app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php:94)
Hope this helps for this case. |
Could reproduce the issue. |
@stevenvdp thank you for diving into it! @rganin we actually do have some extensions related to url-keys, but they should not interact in that way. But I am happy to test the eventual fix against our extension. |
We also run into a very similar problem, which happens after trying to create url rewrites in an automated category/product import job. What seems to fix it, is these two changes (based on the Magento 2.1.2 codebase):
diff --git a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php
index 6539a95..92ae0ec 100644
--- a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php
+++ b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php
@@ -108,7 +108,8 @@ class ProductUrlRewriteGenerator
$productCategories = $product->getCategoryCollection()
->addAttributeToSelect('url_key')
- ->addAttributeToSelect('url_path');
+ ->addAttributeToSelect('url_path')
+ ->setStoreId($storeId);
$urls = $this->isGlobalScope($storeId)
? $this->generateForGlobalScope($productCategories)
diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php
index 972b5c0..8845c7a 100644
--- a/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php
+++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php
@@ -55,7 +55,7 @@ class AnchorUrlRewriteGenerator
$anchorCategoryIds = $category->getAnchorsAbove();
if ($anchorCategoryIds) {
foreach ($anchorCategoryIds as $anchorCategoryId) {
- $anchorCategory = $this->categoryRepository->get($anchorCategoryId);
+ $anchorCategory = $this->categoryRepository->get($anchorCategoryId, $storeId);
$urls[] = $this->urlRewriteFactory->create()
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
->setEntityId($product->getId()) |
This issue was fixed for ver. 2.1. |
Hi @veloraven could you please reference a particular version (2.1.6, 2.1.7, etc.)? Or at least a commit that fixes the issue? |
Hi @veloraven you said that this was fixed for 2.1, but I still have this issue on 2.1.10 and 2.2. So where this is fixed? |
This is still not fixed for the AnchorUrlRewriteGenerator. This is the patch I'm using in the meantime;
|
Hm it seems that @hostep already applied this fix but later on it was reverted again. |
@peterjaap: it was never accepted, I purposely closed the PR since it caused too many negative side effects, I can't remember which ones though... But there is a new pending PR which might get merged someday: #14344 |
[borg] MAGETWO-99307: Authorize.net Transaction Fails but Order goes through
Hi @bh-ref. Thank you for your report.
The fix will be available with the upcoming 2.4.0 release. |
@olga Moyseyenko @veloraven |
Preconditions
Steps to reproduce
We have two frontend storeviews in Magento 2.0.4, a French one and a German one. But the parent category url_key in the URL rewrites is always the German one, for both, the german and the french storeview.
Expected result
Expected URL rewrite for a sub-category:
https://example.com/fr/french-parent-category/french-sub-category/
Expected URL rewrite for a product:
https://example.com/fr/french-parent-category/french-product/
Actual result
Actual URL rewrite for sub-category:
https://example.com/fr/german-parent-category/french-sub-category/
Actual URL rewrite for a product:
https://example.com/fr/german-parent-category/french-product/
The text was updated successfully, but these errors were encountered: