Skip to content

After upgrade to 2.1.3 url rewrite problem multi store #8227

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
philipvandebriel opened this issue Jan 22, 2017 · 27 comments
Closed

After upgrade to 2.1.3 url rewrite problem multi store #8227

philipvandebriel opened this issue Jan 22, 2017 · 27 comments
Labels
bug report Component: CatalogUrlRewrite Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@philipvandebriel
Copy link

Preconditions

  1. Magento 2.1.3
  2. Nginx/Debian8/Mysql

Steps to reproduce

  1. Add new product or
  2. change old url and save product or
  3. delete a url and save product

Expected result

  1. url rewrite like this ( in 2.1.2 everything ok ) www.domain.com/xxxxxxx.html

Actual result

  1. we get an url like this : catalog/product/view/id/7775/s/XXXXXXXXXXXXX/

If we check the url rewrite table in the database then all the url's are deleted with product id 7775
If we save the product nothing change and can not found the urls anymore in de url rewrite table.

If we save a product (from magento 2.1.2) and don't change the url then the rewrite-url is ok.
We use multistore with url store code.

@naydav
Copy link
Contributor

naydav commented Feb 1, 2017

Unfortunately, I could not reproduce the issue as you described it on 2.1.3 version. Please provide the detailed steps we must follow to reproduce this issue.
Need more information about:

  • Do you have got problem after upgrading from 2.1.2 to 2.1.3 or you use clean 2.1.3 installation?
  • Do you have several store views on one website?
  • Specify what Product Url key you entered at product creation.
  • Specify what Product Url key you entered at product updating. Did you check "Create Permanent Redirect for old URL" checkbox while product url updating?
  • What does it mean "delete a url"?
    Please provide detailed steps to replicate issue
    Thanks in advance

@philipvandebriel
Copy link
Author

@naydav

  • Yes we did an upgrade from 2.1.2 to 2.1.3
  • We have 6 storeviews on 1 website
  • We use the name from the product as Pruduct Url, if we delete the url and saved again without url then we can't found the url_key anymore in the table URL_REWRITE.
  • we try with and without check Permanent Redirect 301 url.
  • Delete a url means , we delete the url key from the product and save the product again. After we can found anymore the product url in the url_rewrite table. (example product 7775)
  • ALso we never delete self something in the URL_REWRITE table.
  • Categories url-rewrites everything normally
    schermafdruk 2017-02-01 18 01 47
    schermafdruk 2017-02-01 18 02 53
    schermafdruk 2017-02-01 18 11 55

@naydav
Copy link
Contributor

naydav commented Feb 2, 2017

I still could not reproduce the issue.

Steps to reproduce:

  1. Install Magento 2.1.2. Single-Store mode is disabled.
  2. Create two store views (store_2, store_3), enable them and assign to Main Website Store (Stores > All Stores)
  3. Create two Simple Products (with URL Keys: product-1, product-2). Assign created products to new category Cat-1

Db state after steps:
8227-1

Pay attention:
request_path - it is URL path to reach product on frontend
target_path - it is how to this request_path will be processed in Magento internally

Created products are reacheable on frontend by next urls:

Product 1:
magento2.1.local/product-1.html
magento2.1.local/cat-1/product-1.html

Product 2:
magento2.1.local/product-2.html
magento2.1.local/cat-1/product-2.html

  1. Up Magento version to 2.1.3

    • update code via git or composer
    • run "php bin/magento setup:upgrade"
    • update static if needed (php bin/magento setup:static-content:deploy)
    • run "php bin/magento --version". Result is Magento CLI version 2.1.3
  2. Open "Product-1" edit page in Magento admin panel. Change "Search Engine Optimization > URL Key" field on "product-1-2" (Create Permanent Redirect for old URL is checked). Save product.

  3. Open "Product-2" edit page in Magento admin panel. Delete the value from "Search Engine Optimization > URL Key" (Create Permanent Redirect for old URL is unchecked). Save product.

Db state after steps:
8227-2

Our products are reacheable on frontend by next URLs:

Product 1:
magento2.1.local/product-1.html will be redirected(301) on magento2.1.local/product-1-2.html
magento2.1.local/cat-1/product-1.html will be redirected(301) on magento2.1.local/cat-1/product-1-2.html
magento2.1.local/product-1-2.html
magento2.1.local/cat-1/product-1-2.html

Product 2:
magento2.1.local/product-2.html
magento2.1.local/cat-1/product-2.html

So, all works properly.

Aditional questions:

  • Provide "Stores >Configuration > Catalog > Search Engine Optimization" settings (per store)
  • How do you perform the Magento update?
  • How do you get "catalog/product/view/id/7775/s/XXXXXXXXXXXXX/" URL? Did you click on category menu (or some custom element)?
  • Does product have custom settings?

@philipvandebriel
Copy link
Author

Okay maybe i can explaine it better now ,
part 1

  • one website 5 storeviews
  • product ID 7791
  • Storeview 1,2,3,5 have url key with "use default value" check for url_key
    schermafdruk 2017-02-05 10 50 15
  • Last url_rewrite_id is 1241328

part 2

  • Go to products=>catalog=>edit product 7791=>uncheck use default value and change url_key
  • Save product
  • Now i have the url key from store 4 in my url_rewrite table
    schermafdruk 2017-02-05 10 50 51
  • Last url_rewrite_id is 1241329 ( add 1 url key in my url_rewrite table), everything ok

** Part 3 **

  • Go to products=>catalog=>check product 7791=>Actions=>update attributes=>websites=>Add Product To Websites - check main website=>SAVE
  • if i open my url_table then i see now 5 url_rewrites deleted and i get 4 new url_rewrites except for store 4. So only if i check default value then i get a url_rewrite.
    schermafdruk 2017-02-05 10 52 57
  • Last url_rewrite_id is 1241330-1241333

@naydav
Copy link
Contributor

naydav commented Feb 6, 2017

Thanks
I was able to reproduce the issue.
Created internal issue MAGETWO-64191 to investigate and track this issue.

Thanks in advance

@naydav naydav added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Feb 6, 2017
@philipvandebriel
Copy link
Author

@naydav is there a fix in magento 2.1.4 ?

@philipvandebriel
Copy link
Author

@naydav Same problem in Magento 2.1.4 !

@naydav naydav removed their assignment Feb 8, 2017
@peterkeijsers
Copy link

peterkeijsers commented Apr 7, 2017

I have similar problems. It seems to be related to updating the website attribute of the product. I have a product with 4 url_key values set at storeview scope and 2 url_key values at default scope. At first the product seems oke. All 6 url_keys are stored in the url_rewrite table and all is fine.
When I mass-update this product via the backend, and I allocate the product to my website (again, as it already was allocated to it) then all url_rewrite entries dissappear except for those whose url_key value is set on default scope.

So triggering an update of this 'website' attribute is causing url_rewrite entries to dissappear somehow.

@thlassche
Copy link
Contributor

I developed a solution that can regenerate the rewrites using the CLI, which fixes the above for me. Contact me if you need it.

@heresh80
Copy link

I need it thlassche!

@thlassche
Copy link
Contributor

@heresh80 Can't find your e-mail, please drop me an e-mail on [email protected]

@FranRoy
Copy link

FranRoy commented Aug 30, 2017

Hi, I'm using magento 2.1.7 with 2 stores and it happens to me to products that are in both websites.
Is there any update?

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Progress: needs update Component: CatalogUrlRewrite Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@BarnyShergold
Copy link

We have 2 M2 instances where we are getting this issue -

A product on the M2 instance is allocated to two websites, it has not been modified for nearly a year (the timestamps on catalog_product_entity) and was working fine on both sites. At some point recently the URL of the product has reverted to catalog/product/view/id/1083/s/..... form on ONE of the websites, on the other it is still fine. Checking the url_rewrite table shows that the entries for this product on the affected site are all gone.

It sounds like our issue is related to this open issue but the rewrites are being deleted without the product being updated - does anyone have any comments?

@real34
Copy link
Member

real34 commented Jan 25, 2018

Same here!

In our case, the store has been migrated from M1 using the data migration tool. We haven’t yet checked on a fresh M2 install with sample data…

@magento-engcom-team
Copy link
Contributor

Hi @philipvandebriel. Thank you for your report.
The issue has been fixed in #13567 by @adrien-louis-r in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.4 release.

@magento-engcom-team
Copy link
Contributor

Hi @philipvandebriel. Thank you for your report.
The issue has been fixed in #14252 by @rostyslav-hymon in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Mar 23, 2018
@OZZlE
Copy link
Contributor

OZZlE commented Apr 4, 2018

@magento-engcom-team those commits you refer to seems to be only test cases rather than the actual fix? I'm trying to backport this to 2.1.12 also...

@aloross
Copy link

aloross commented Apr 4, 2018

@OZZlE, quoting myself from the associated PR.

We discovered that, in the 2.2-dev branch, the issue was fixed by side effect in this commit: a0d3a63. This PR just provide the tests we were using when fixing the issue but the fix itself is already merged (see: a0d3a63#diff-4e1fd4e484fc5142fc23f8ef0cde6718L53).

@OZZlE
Copy link
Contributor

OZZlE commented Apr 11, 2018

@adrien-louis-r it was another bug in <2.3

Looks like a bug in catalog-search module.

It uses websiteId instead storeId when building tmp search table.

Here is diff comparing to 2.2.3:

Patching this fixed the issue with missing products in grid.

+++ ./Model/Search/FilterMapper/TermDropdownStrategy.php	(date 1523456583000)
@@ -98,7 +98,7 @@
             'search_index.entity_id = %1$s.entity_id AND %1$s.attribute_id = %2$d AND %1$s.store_id = %3$d',
             $alias,
             $attribute->getId(),
-            $this->storeManager->getWebsite()->getId()
+            $this->storeManager->getStore()->getId()
         );
         $select->joinLeft(
             [$alias => $this->resourceConnection->getTableName('catalog_product_index_eav')],```

@peterjaap
Copy link
Contributor

@magento-engcom-team that is not the fix, that is just an integration test. Could you refer us to the actual commit that fixes it?

@samuel27m
Copy link
Member

Anyone looking to backport this issue, the workaround that worked for me with Magento 2.1.6 was commeting the line 144 of file vendor/magento/module-catalog-url-rewrite/Model/ProductUrlRewriteGenerator.php or app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php, depends on your folder structure

Still trying to find any problems with this approach, none so far

@peterjaap
Copy link
Contributor

peterjaap commented Aug 29, 2018

@samuel27m could you link to that exact line in the Github repo? In my 2.2.5 installation that line is return $urls; which I doubt is the line you mean.

Found it; https://github.com/magento/magento2/blob/2.1.6/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php#L144

@samuel27m
Copy link
Member

@peterjaap yes, exactly that one.
Do you know if there any problem that removing that line can bring up? I've ran many tests creating and removing product URL's but no errors so far.

@XstraAI
Copy link

XstraAI commented Oct 30, 2018

I am experiencing this on 2.2.4. Can anyone confirm if this issue has been resolved in a later release?
Any other workarounds in the meantime?

magento-engcom-team pushed a commit that referenced this issue Feb 3, 2019
Fixed:
MAGETWO-64191 [GITHUB] Url rewrite for product is broken after using massaction #8227
MAGETWO-96411 [2.3.x] Default addresses not selected when checking out from cart
MAGETWO-96849 [2.3.x] Money are refunded to gift card during partial refund when it's not required
MAGETWO-96846 [2.3.x] Anchor categories are not showing products after enabling subcategories
MC-5573 Refactoring tests. Improve specified test cases.
MC-10934 Tests failures CreationScheduledUpdateForStagingDashboardTest and StorefrontPurchaseProductWithCustomOptions
MAGETWO-91676 related data missing in order rest api
@jagoman85
Copy link

@hi-soni
Copy link

hi-soni commented Dec 4, 2020

I am facing the same issue for the category after upgrading Magento 2.4.0 to Magento 2.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: CatalogUrlRewrite Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests