Magento 2| Url regeneration for catalogCustom URL rewrites for categories and productsCatalog URL indexer weird behaviourMagento 2 URL rewrite appending .html.htmlHow to delete and regenerate URL rewrites in Magento 2?Product url displaying category-ID and product-IDModify dynamically created product url in magento 2Magento 2 : Product URL rewrite issueMagento 2: “Use Categories Path for Product URLs” configuration does not working correctlyMagento2: Remove Category path from product URL is not workingURL Key not changing in Magento 2

Is there a hemisphere-neutral way of specifying a season?

Will google still index a page if I use a $_SESSION variable?

Why is the 'in' operator throwing an error with a string literal instead of logging false?

1960's book about a plague that kills all white people

How do conventional missiles fly?

Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?

Is Lorentz symmetry broken if SUSY is broken?

Twin primes whose sum is a cube

Infinite Abelian subgroup of infinite non Abelian group example

What's the difference between 'rename' and 'mv'?

What killed these X2 caps?

Why is consensus so controversial in Britain?

Could gravitational lensing be used to protect a spaceship from a laser?

What is going on with Captain Marvel's blood colour?

Why can't we play rap on piano?

Intersection of two sorted vectors in C++

Theorems that impeded progress

How could indestructible materials be used in power generation?

prove that the matrix A is diagonalizable

Memorizing the Keyboard

Alternative to sending password over mail?

How to say in German "enjoying home comforts"

Were any external disk drives stacked vertically?

How can I tell someone that I want to be his or her friend?



Magento 2| Url regeneration for catalog


Custom URL rewrites for categories and productsCatalog URL indexer weird behaviourMagento 2 URL rewrite appending .html.htmlHow to delete and regenerate URL rewrites in Magento 2?Product url displaying category-ID and product-IDModify dynamically created product url in magento 2Magento 2 : Product URL rewrite issueMagento 2: “Use Categories Path for Product URLs” configuration does not working correctlyMagento2: Remove Category path from product URL is not workingURL Key not changing in Magento 2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I have tried to regenerate urls for categories and products after migration from Magento 1.9.x to Magento 2.2.x through following modules:




  1. Url Regenerator 1

  2. Url Regenerator 2

These 2 generates the urls for categories and products but in frontend, I am getting 404 error when click on products from Homepage, search result page, any widgets etc. Product urls works fine when going from category pages but not for all categories. From some of the categories its shows 404.



Good thing is that all category urls are working perfectly. But not the product urls.



I have multiple stores. Anyone have the same issues?










share|improve this question
















bumped to the homepage by Community 4 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • are you sure that you do not have any duplicate url_keys in your shop, maybe for some store views? For products that give a 404: does the same product give a 404 in every store view, or different products in different store views, that work in another one?

    – simonthesorcerer
    Oct 15 '18 at 6:08











  • also, what is your setting for "use category in product URLs"?

    – simonthesorcerer
    Oct 15 '18 at 6:08











  • I have already truncate the tables

    – Sukumar Gorai
    Oct 15 '18 at 6:10











  • No I am not using use category path in product urls.

    – Sukumar Gorai
    Oct 15 '18 at 6:11

















3















I have tried to regenerate urls for categories and products after migration from Magento 1.9.x to Magento 2.2.x through following modules:




  1. Url Regenerator 1

  2. Url Regenerator 2

These 2 generates the urls for categories and products but in frontend, I am getting 404 error when click on products from Homepage, search result page, any widgets etc. Product urls works fine when going from category pages but not for all categories. From some of the categories its shows 404.



Good thing is that all category urls are working perfectly. But not the product urls.



I have multiple stores. Anyone have the same issues?










share|improve this question
















bumped to the homepage by Community 4 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • are you sure that you do not have any duplicate url_keys in your shop, maybe for some store views? For products that give a 404: does the same product give a 404 in every store view, or different products in different store views, that work in another one?

    – simonthesorcerer
    Oct 15 '18 at 6:08











  • also, what is your setting for "use category in product URLs"?

    – simonthesorcerer
    Oct 15 '18 at 6:08











  • I have already truncate the tables

    – Sukumar Gorai
    Oct 15 '18 at 6:10











  • No I am not using use category path in product urls.

    – Sukumar Gorai
    Oct 15 '18 at 6:11













3












3








3








I have tried to regenerate urls for categories and products after migration from Magento 1.9.x to Magento 2.2.x through following modules:




  1. Url Regenerator 1

  2. Url Regenerator 2

These 2 generates the urls for categories and products but in frontend, I am getting 404 error when click on products from Homepage, search result page, any widgets etc. Product urls works fine when going from category pages but not for all categories. From some of the categories its shows 404.



Good thing is that all category urls are working perfectly. But not the product urls.



I have multiple stores. Anyone have the same issues?










share|improve this question
















I have tried to regenerate urls for categories and products after migration from Magento 1.9.x to Magento 2.2.x through following modules:




  1. Url Regenerator 1

  2. Url Regenerator 2

These 2 generates the urls for categories and products but in frontend, I am getting 404 error when click on products from Homepage, search result page, any widgets etc. Product urls works fine when going from category pages but not for all categories. From some of the categories its shows 404.



Good thing is that all category urls are working perfectly. But not the product urls.



I have multiple stores. Anyone have the same issues?







magento2 url-rewrite magento2.2.4 product-urls regenerate






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 28 '18 at 4:30







Sukumar Gorai

















asked Sep 27 '18 at 14:47









Sukumar GoraiSukumar Gorai

6,9303729




6,9303729





bumped to the homepage by Community 4 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 4 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • are you sure that you do not have any duplicate url_keys in your shop, maybe for some store views? For products that give a 404: does the same product give a 404 in every store view, or different products in different store views, that work in another one?

    – simonthesorcerer
    Oct 15 '18 at 6:08











  • also, what is your setting for "use category in product URLs"?

    – simonthesorcerer
    Oct 15 '18 at 6:08











  • I have already truncate the tables

    – Sukumar Gorai
    Oct 15 '18 at 6:10











  • No I am not using use category path in product urls.

    – Sukumar Gorai
    Oct 15 '18 at 6:11

















  • are you sure that you do not have any duplicate url_keys in your shop, maybe for some store views? For products that give a 404: does the same product give a 404 in every store view, or different products in different store views, that work in another one?

    – simonthesorcerer
    Oct 15 '18 at 6:08











  • also, what is your setting for "use category in product URLs"?

    – simonthesorcerer
    Oct 15 '18 at 6:08











  • I have already truncate the tables

    – Sukumar Gorai
    Oct 15 '18 at 6:10











  • No I am not using use category path in product urls.

    – Sukumar Gorai
    Oct 15 '18 at 6:11
















are you sure that you do not have any duplicate url_keys in your shop, maybe for some store views? For products that give a 404: does the same product give a 404 in every store view, or different products in different store views, that work in another one?

– simonthesorcerer
Oct 15 '18 at 6:08





are you sure that you do not have any duplicate url_keys in your shop, maybe for some store views? For products that give a 404: does the same product give a 404 in every store view, or different products in different store views, that work in another one?

– simonthesorcerer
Oct 15 '18 at 6:08













also, what is your setting for "use category in product URLs"?

– simonthesorcerer
Oct 15 '18 at 6:08





also, what is your setting for "use category in product URLs"?

– simonthesorcerer
Oct 15 '18 at 6:08













I have already truncate the tables

– Sukumar Gorai
Oct 15 '18 at 6:10





I have already truncate the tables

– Sukumar Gorai
Oct 15 '18 at 6:10













No I am not using use category path in product urls.

– Sukumar Gorai
Oct 15 '18 at 6:11





No I am not using use category path in product urls.

– Sukumar Gorai
Oct 15 '18 at 6:11










2 Answers
2






active

oldest

votes


















0














Truncate all product/category urls from url_rewrite table and then regenerate them by saving a parent cateogory (after modifying either is_anchor or url_key field).






share|improve this answer























  • I have 60 parent category and around 1800 sub categories. It's taking around 10 mins to save one category so it's not a solution.

    – Sukumar Gorai
    Oct 14 '18 at 19:24











  • try saving only the root category.

    – Siju Joseph
    Oct 16 '18 at 15:08











  • Tried but no luck.

    – Sukumar Gorai
    Oct 16 '18 at 18:36


















0














Magento 1 had an indexer which regenerate url rewrites automatically each run of that indexer. This was quite comfortable. The only problem were shops with a lot of products. The more products and the more rewrites, the longer this indexer runs. So for performance optimization it was a good idea to remove this indexer for Magento 2. But this has other drawbacks…




Problem




An url rewrite is required for seo optimized shop urls.



Magento 2 do not automatically create rewrites. They are only computed if you do an action like save category. This makes sense if you create categories and products in you backend. If you import these things by code, you have to save all categories manually after each import. No solution for a programmer…




Solution




A quite simple solution is to use a ready to run Magento 2 module which does exactly the work of an rewrite indexer. A programmer did that an offers his module magento2-regenurl on github. You can call this regeneration by code or from command line. A better solution is to do it by code in your own importer module. The regeneration is quite simple:



foreach($list as $product) 
if($store_id === Store::DEFAULT_STORE_ID)
$product->setStoreId($store_id);
$this->urlPersist->deleteByData([
UrlRewrite::ENTITY_ID => $product->getId(),
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
UrlRewrite::REDIRECT_TYPE => 0,
UrlRewrite::STORE_ID => $store_id
]);
try
$this->urlPersist->replace(
$this->productUrlRewriteGenerator->generate($product)
);
catch(Exception $e)
$out->writeln('Duplicated url for '. $product->getId() .'');




As you can see Magento 2 offers you a model for regenerate url rewrites




MagentoCatalogUrlRewriteModelProductUrlRewriteGenerator




(productUrlRewriteGenerator) which you can inject into your model. This generated url rewrite can be replaced by MagentoUrlRewriteModelUrlPersistInterface (urlPersist). You can run this in a loop for all products after import or for each single product after a change.



You find url rewrites in url_rewrite table in you database. This is exactly the same as in Magento 1.



I recently found this Magento 2 Module on GitHub
which fixes all my problems. I can recomend it. You can simply regenerate all your url rewrites for products and categories with the following command:




bin/magento ok:urlrewrites:regenerate




I Hope that helps!






share|improve this answer


















  • 1





    If you check my question, then you will find that I have already tried the plug-in you are asking.

    – Sukumar Gorai
    Oct 15 '18 at 5:22











  • I have shared 2 module link github.com/Iazel/magento2-regenurl and github.com/olegkoval/magento2-regenerate_url_rewrites and possible problem and process of magento 1 & magento 2 for reganrate URL. so you can verify it.

    – Chirag Patel
    Oct 15 '18 at 5:29











  • Because you faced this problem because your regenerate URL not working properly.

    – Chirag Patel
    Oct 15 '18 at 5:30











  • Can you check my question, I have already tried these modules. But no luck.

    – Sukumar Gorai
    Oct 15 '18 at 5:30












  • I am creating my own module so far its working fine for products. Working with categories.

    – Sukumar Gorai
    Oct 15 '18 at 5:31











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f244163%2fmagento-2-url-regeneration-for-catalog%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Truncate all product/category urls from url_rewrite table and then regenerate them by saving a parent cateogory (after modifying either is_anchor or url_key field).






share|improve this answer























  • I have 60 parent category and around 1800 sub categories. It's taking around 10 mins to save one category so it's not a solution.

    – Sukumar Gorai
    Oct 14 '18 at 19:24











  • try saving only the root category.

    – Siju Joseph
    Oct 16 '18 at 15:08











  • Tried but no luck.

    – Sukumar Gorai
    Oct 16 '18 at 18:36















0














Truncate all product/category urls from url_rewrite table and then regenerate them by saving a parent cateogory (after modifying either is_anchor or url_key field).






share|improve this answer























  • I have 60 parent category and around 1800 sub categories. It's taking around 10 mins to save one category so it's not a solution.

    – Sukumar Gorai
    Oct 14 '18 at 19:24











  • try saving only the root category.

    – Siju Joseph
    Oct 16 '18 at 15:08











  • Tried but no luck.

    – Sukumar Gorai
    Oct 16 '18 at 18:36













0












0








0







Truncate all product/category urls from url_rewrite table and then regenerate them by saving a parent cateogory (after modifying either is_anchor or url_key field).






share|improve this answer













Truncate all product/category urls from url_rewrite table and then regenerate them by saving a parent cateogory (after modifying either is_anchor or url_key field).







share|improve this answer












share|improve this answer



share|improve this answer










answered Oct 14 '18 at 19:02









Siju JosephSiju Joseph

62955




62955












  • I have 60 parent category and around 1800 sub categories. It's taking around 10 mins to save one category so it's not a solution.

    – Sukumar Gorai
    Oct 14 '18 at 19:24











  • try saving only the root category.

    – Siju Joseph
    Oct 16 '18 at 15:08











  • Tried but no luck.

    – Sukumar Gorai
    Oct 16 '18 at 18:36

















  • I have 60 parent category and around 1800 sub categories. It's taking around 10 mins to save one category so it's not a solution.

    – Sukumar Gorai
    Oct 14 '18 at 19:24











  • try saving only the root category.

    – Siju Joseph
    Oct 16 '18 at 15:08











  • Tried but no luck.

    – Sukumar Gorai
    Oct 16 '18 at 18:36
















I have 60 parent category and around 1800 sub categories. It's taking around 10 mins to save one category so it's not a solution.

– Sukumar Gorai
Oct 14 '18 at 19:24





I have 60 parent category and around 1800 sub categories. It's taking around 10 mins to save one category so it's not a solution.

– Sukumar Gorai
Oct 14 '18 at 19:24













try saving only the root category.

– Siju Joseph
Oct 16 '18 at 15:08





try saving only the root category.

– Siju Joseph
Oct 16 '18 at 15:08













Tried but no luck.

– Sukumar Gorai
Oct 16 '18 at 18:36





Tried but no luck.

– Sukumar Gorai
Oct 16 '18 at 18:36













0














Magento 1 had an indexer which regenerate url rewrites automatically each run of that indexer. This was quite comfortable. The only problem were shops with a lot of products. The more products and the more rewrites, the longer this indexer runs. So for performance optimization it was a good idea to remove this indexer for Magento 2. But this has other drawbacks…




Problem




An url rewrite is required for seo optimized shop urls.



Magento 2 do not automatically create rewrites. They are only computed if you do an action like save category. This makes sense if you create categories and products in you backend. If you import these things by code, you have to save all categories manually after each import. No solution for a programmer…




Solution




A quite simple solution is to use a ready to run Magento 2 module which does exactly the work of an rewrite indexer. A programmer did that an offers his module magento2-regenurl on github. You can call this regeneration by code or from command line. A better solution is to do it by code in your own importer module. The regeneration is quite simple:



foreach($list as $product) 
if($store_id === Store::DEFAULT_STORE_ID)
$product->setStoreId($store_id);
$this->urlPersist->deleteByData([
UrlRewrite::ENTITY_ID => $product->getId(),
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
UrlRewrite::REDIRECT_TYPE => 0,
UrlRewrite::STORE_ID => $store_id
]);
try
$this->urlPersist->replace(
$this->productUrlRewriteGenerator->generate($product)
);
catch(Exception $e)
$out->writeln('Duplicated url for '. $product->getId() .'');




As you can see Magento 2 offers you a model for regenerate url rewrites




MagentoCatalogUrlRewriteModelProductUrlRewriteGenerator




(productUrlRewriteGenerator) which you can inject into your model. This generated url rewrite can be replaced by MagentoUrlRewriteModelUrlPersistInterface (urlPersist). You can run this in a loop for all products after import or for each single product after a change.



You find url rewrites in url_rewrite table in you database. This is exactly the same as in Magento 1.



I recently found this Magento 2 Module on GitHub
which fixes all my problems. I can recomend it. You can simply regenerate all your url rewrites for products and categories with the following command:




bin/magento ok:urlrewrites:regenerate




I Hope that helps!






share|improve this answer


















  • 1





    If you check my question, then you will find that I have already tried the plug-in you are asking.

    – Sukumar Gorai
    Oct 15 '18 at 5:22











  • I have shared 2 module link github.com/Iazel/magento2-regenurl and github.com/olegkoval/magento2-regenerate_url_rewrites and possible problem and process of magento 1 & magento 2 for reganrate URL. so you can verify it.

    – Chirag Patel
    Oct 15 '18 at 5:29











  • Because you faced this problem because your regenerate URL not working properly.

    – Chirag Patel
    Oct 15 '18 at 5:30











  • Can you check my question, I have already tried these modules. But no luck.

    – Sukumar Gorai
    Oct 15 '18 at 5:30












  • I am creating my own module so far its working fine for products. Working with categories.

    – Sukumar Gorai
    Oct 15 '18 at 5:31















0














Magento 1 had an indexer which regenerate url rewrites automatically each run of that indexer. This was quite comfortable. The only problem were shops with a lot of products. The more products and the more rewrites, the longer this indexer runs. So for performance optimization it was a good idea to remove this indexer for Magento 2. But this has other drawbacks…




Problem




An url rewrite is required for seo optimized shop urls.



Magento 2 do not automatically create rewrites. They are only computed if you do an action like save category. This makes sense if you create categories and products in you backend. If you import these things by code, you have to save all categories manually after each import. No solution for a programmer…




Solution




A quite simple solution is to use a ready to run Magento 2 module which does exactly the work of an rewrite indexer. A programmer did that an offers his module magento2-regenurl on github. You can call this regeneration by code or from command line. A better solution is to do it by code in your own importer module. The regeneration is quite simple:



foreach($list as $product) 
if($store_id === Store::DEFAULT_STORE_ID)
$product->setStoreId($store_id);
$this->urlPersist->deleteByData([
UrlRewrite::ENTITY_ID => $product->getId(),
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
UrlRewrite::REDIRECT_TYPE => 0,
UrlRewrite::STORE_ID => $store_id
]);
try
$this->urlPersist->replace(
$this->productUrlRewriteGenerator->generate($product)
);
catch(Exception $e)
$out->writeln('Duplicated url for '. $product->getId() .'');




As you can see Magento 2 offers you a model for regenerate url rewrites




MagentoCatalogUrlRewriteModelProductUrlRewriteGenerator




(productUrlRewriteGenerator) which you can inject into your model. This generated url rewrite can be replaced by MagentoUrlRewriteModelUrlPersistInterface (urlPersist). You can run this in a loop for all products after import or for each single product after a change.



You find url rewrites in url_rewrite table in you database. This is exactly the same as in Magento 1.



I recently found this Magento 2 Module on GitHub
which fixes all my problems. I can recomend it. You can simply regenerate all your url rewrites for products and categories with the following command:




bin/magento ok:urlrewrites:regenerate




I Hope that helps!






share|improve this answer


















  • 1





    If you check my question, then you will find that I have already tried the plug-in you are asking.

    – Sukumar Gorai
    Oct 15 '18 at 5:22











  • I have shared 2 module link github.com/Iazel/magento2-regenurl and github.com/olegkoval/magento2-regenerate_url_rewrites and possible problem and process of magento 1 & magento 2 for reganrate URL. so you can verify it.

    – Chirag Patel
    Oct 15 '18 at 5:29











  • Because you faced this problem because your regenerate URL not working properly.

    – Chirag Patel
    Oct 15 '18 at 5:30











  • Can you check my question, I have already tried these modules. But no luck.

    – Sukumar Gorai
    Oct 15 '18 at 5:30












  • I am creating my own module so far its working fine for products. Working with categories.

    – Sukumar Gorai
    Oct 15 '18 at 5:31













0












0








0







Magento 1 had an indexer which regenerate url rewrites automatically each run of that indexer. This was quite comfortable. The only problem were shops with a lot of products. The more products and the more rewrites, the longer this indexer runs. So for performance optimization it was a good idea to remove this indexer for Magento 2. But this has other drawbacks…




Problem




An url rewrite is required for seo optimized shop urls.



Magento 2 do not automatically create rewrites. They are only computed if you do an action like save category. This makes sense if you create categories and products in you backend. If you import these things by code, you have to save all categories manually after each import. No solution for a programmer…




Solution




A quite simple solution is to use a ready to run Magento 2 module which does exactly the work of an rewrite indexer. A programmer did that an offers his module magento2-regenurl on github. You can call this regeneration by code or from command line. A better solution is to do it by code in your own importer module. The regeneration is quite simple:



foreach($list as $product) 
if($store_id === Store::DEFAULT_STORE_ID)
$product->setStoreId($store_id);
$this->urlPersist->deleteByData([
UrlRewrite::ENTITY_ID => $product->getId(),
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
UrlRewrite::REDIRECT_TYPE => 0,
UrlRewrite::STORE_ID => $store_id
]);
try
$this->urlPersist->replace(
$this->productUrlRewriteGenerator->generate($product)
);
catch(Exception $e)
$out->writeln('Duplicated url for '. $product->getId() .'');




As you can see Magento 2 offers you a model for regenerate url rewrites




MagentoCatalogUrlRewriteModelProductUrlRewriteGenerator




(productUrlRewriteGenerator) which you can inject into your model. This generated url rewrite can be replaced by MagentoUrlRewriteModelUrlPersistInterface (urlPersist). You can run this in a loop for all products after import or for each single product after a change.



You find url rewrites in url_rewrite table in you database. This is exactly the same as in Magento 1.



I recently found this Magento 2 Module on GitHub
which fixes all my problems. I can recomend it. You can simply regenerate all your url rewrites for products and categories with the following command:




bin/magento ok:urlrewrites:regenerate




I Hope that helps!






share|improve this answer













Magento 1 had an indexer which regenerate url rewrites automatically each run of that indexer. This was quite comfortable. The only problem were shops with a lot of products. The more products and the more rewrites, the longer this indexer runs. So for performance optimization it was a good idea to remove this indexer for Magento 2. But this has other drawbacks…




Problem




An url rewrite is required for seo optimized shop urls.



Magento 2 do not automatically create rewrites. They are only computed if you do an action like save category. This makes sense if you create categories and products in you backend. If you import these things by code, you have to save all categories manually after each import. No solution for a programmer…




Solution




A quite simple solution is to use a ready to run Magento 2 module which does exactly the work of an rewrite indexer. A programmer did that an offers his module magento2-regenurl on github. You can call this regeneration by code or from command line. A better solution is to do it by code in your own importer module. The regeneration is quite simple:



foreach($list as $product) 
if($store_id === Store::DEFAULT_STORE_ID)
$product->setStoreId($store_id);
$this->urlPersist->deleteByData([
UrlRewrite::ENTITY_ID => $product->getId(),
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
UrlRewrite::REDIRECT_TYPE => 0,
UrlRewrite::STORE_ID => $store_id
]);
try
$this->urlPersist->replace(
$this->productUrlRewriteGenerator->generate($product)
);
catch(Exception $e)
$out->writeln('Duplicated url for '. $product->getId() .'');




As you can see Magento 2 offers you a model for regenerate url rewrites




MagentoCatalogUrlRewriteModelProductUrlRewriteGenerator




(productUrlRewriteGenerator) which you can inject into your model. This generated url rewrite can be replaced by MagentoUrlRewriteModelUrlPersistInterface (urlPersist). You can run this in a loop for all products after import or for each single product after a change.



You find url rewrites in url_rewrite table in you database. This is exactly the same as in Magento 1.



I recently found this Magento 2 Module on GitHub
which fixes all my problems. I can recomend it. You can simply regenerate all your url rewrites for products and categories with the following command:




bin/magento ok:urlrewrites:regenerate




I Hope that helps!







share|improve this answer












share|improve this answer



share|improve this answer










answered Oct 15 '18 at 5:09









Chirag PatelChirag Patel

2,468423




2,468423







  • 1





    If you check my question, then you will find that I have already tried the plug-in you are asking.

    – Sukumar Gorai
    Oct 15 '18 at 5:22











  • I have shared 2 module link github.com/Iazel/magento2-regenurl and github.com/olegkoval/magento2-regenerate_url_rewrites and possible problem and process of magento 1 & magento 2 for reganrate URL. so you can verify it.

    – Chirag Patel
    Oct 15 '18 at 5:29











  • Because you faced this problem because your regenerate URL not working properly.

    – Chirag Patel
    Oct 15 '18 at 5:30











  • Can you check my question, I have already tried these modules. But no luck.

    – Sukumar Gorai
    Oct 15 '18 at 5:30












  • I am creating my own module so far its working fine for products. Working with categories.

    – Sukumar Gorai
    Oct 15 '18 at 5:31












  • 1





    If you check my question, then you will find that I have already tried the plug-in you are asking.

    – Sukumar Gorai
    Oct 15 '18 at 5:22











  • I have shared 2 module link github.com/Iazel/magento2-regenurl and github.com/olegkoval/magento2-regenerate_url_rewrites and possible problem and process of magento 1 & magento 2 for reganrate URL. so you can verify it.

    – Chirag Patel
    Oct 15 '18 at 5:29











  • Because you faced this problem because your regenerate URL not working properly.

    – Chirag Patel
    Oct 15 '18 at 5:30











  • Can you check my question, I have already tried these modules. But no luck.

    – Sukumar Gorai
    Oct 15 '18 at 5:30












  • I am creating my own module so far its working fine for products. Working with categories.

    – Sukumar Gorai
    Oct 15 '18 at 5:31







1




1





If you check my question, then you will find that I have already tried the plug-in you are asking.

– Sukumar Gorai
Oct 15 '18 at 5:22





If you check my question, then you will find that I have already tried the plug-in you are asking.

– Sukumar Gorai
Oct 15 '18 at 5:22













I have shared 2 module link github.com/Iazel/magento2-regenurl and github.com/olegkoval/magento2-regenerate_url_rewrites and possible problem and process of magento 1 & magento 2 for reganrate URL. so you can verify it.

– Chirag Patel
Oct 15 '18 at 5:29





I have shared 2 module link github.com/Iazel/magento2-regenurl and github.com/olegkoval/magento2-regenerate_url_rewrites and possible problem and process of magento 1 & magento 2 for reganrate URL. so you can verify it.

– Chirag Patel
Oct 15 '18 at 5:29













Because you faced this problem because your regenerate URL not working properly.

– Chirag Patel
Oct 15 '18 at 5:30





Because you faced this problem because your regenerate URL not working properly.

– Chirag Patel
Oct 15 '18 at 5:30













Can you check my question, I have already tried these modules. But no luck.

– Sukumar Gorai
Oct 15 '18 at 5:30






Can you check my question, I have already tried these modules. But no luck.

– Sukumar Gorai
Oct 15 '18 at 5:30














I am creating my own module so far its working fine for products. Working with categories.

– Sukumar Gorai
Oct 15 '18 at 5:31





I am creating my own module so far its working fine for products. Working with categories.

– Sukumar Gorai
Oct 15 '18 at 5:31

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f244163%2fmagento-2-url-regeneration-for-catalog%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2