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

Why doesn't H₄O²⁺ exist?

Neighboring nodes in the network

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

Intersection of two sorted vectors in C++

Can a rocket refuel on Mars from water?

Can I ask the recruiters in my resume to put the reason why I am rejected?

When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?

Is it legal for company to use my work email to pretend I still work there?

How do conventional missiles fly?

Doing something right before you need it - expression for this?

Can one be a co-translator of a book, if he does not know the language that the book is translated into?

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

Is Lorentz symmetry broken if SUSY is broken?

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

How to model explosives?

In a Spin are Both Wings Stalled?

Theorems that impeded progress

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

Why is consensus so controversial in Britain?

Did Shadowfax go to Valinor?

Alternative to sending password over mail?

How to take photos in burst mode, without vibration?

Blender 2.8 I can't see vertices, edges or faces in edit mode

Does a druid starting with a bow start with no arrows?



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

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

Magento 2 disable Secret Key on URL's from terminal The Next CEO of Stack OverflowMagento 2 Shortcut/GUI tool to perform commandline tasks for windowsIn menu add configuration linkMagento oAuth : Generating access token and access secretMagento 2 security key issue in Third-Party API redirect URIPublic actions in admin controllersHow to Disable Cache in Custom WidgetURL Key not changing in Magento 2Product URL Key gets deleted when importing custom options - Magento 2Problem with reindex terminalMagento 2 - bin/magento Commands not working in Cpanel Terminal

Aasi (pallopeli) Navigointivalikko