Magento 2.2.4 The value specified in the URL Key field would generate a URL that already existsMagento 2 Duplicate Product URLs ProblemError, “URL key for specified store already exists” When I'm Adding Products or Moving a CategoryURL key for specified store already exists for category and product alsoProduct Url Key not working rewrite and category say url key specified store already existsWe change the root category to sub category url key is already exists errorMagento 2 : URL key For Specified Store Already ExistsURL key for specified store already exists on Category edit in Magento in Magento 2.1.6URL key for specified store already exists Magento 2Category has not been created. URL key for specified store already existsProduct “Save and Duplicate” errorThe value specified in the URL Key field would generate a URL that already exists
80's-90's TV show or movie about life clocks
Why wasn't EBCDIC designed with contiguous alphanumeric characters?
Making a wall made from glass bricks
Why were the first airplanes "backwards"?
How do pure functions differ from functions defined with SetDelayed?
Can dual citizens open crypto exchange accounts where U.S. citizens are prohibited?
Avoiding repetition when using the "snprintf idiom" to write text
Cup and Trade: The Perfect Nutmeg Soup
Why do movie directors use brown tint on Mexico cities?
Is it okay to submit a paper from a master's thesis without informing the advisor?
How do ohm meters measure high resistances?
How to securely dispose of a smartphone?
Can European countries bypass the EU and make their own individual trade deal with the U.S.?
Does a lens with a bigger max. aperture focus faster than a lens with a smaller max. aperture?
How do I ensure my employees don't abuse my flexible work hours policy?
Do home values typically rise and fall consistently across different price ranges?
Two palindromes are not enough
pgfmath does not work
The Lucas argument vs the theorem-provers--who wins and why?
Does a return economy-class seat between London and San Francisco release 5.28 tonnes of CO2 equivalents?
Origin of the convolution theorem
If I were to build a J3 cub twice the size of the original using the same CG would it fly?
How useful would a hydroelectric plant be in the post-apocalypse world?
I agreed to cancel a long-planned vacation (with travel costs) due to project deadlines, but now the timeline has all changed again
Magento 2.2.4 The value specified in the URL Key field would generate a URL that already exists
Magento 2 Duplicate Product URLs ProblemError, “URL key for specified store already exists” When I'm Adding Products or Moving a CategoryURL key for specified store already exists for category and product alsoProduct Url Key not working rewrite and category say url key specified store already existsWe change the root category to sub category url key is already exists errorMagento 2 : URL key For Specified Store Already ExistsURL key for specified store already exists on Category edit in Magento in Magento 2.1.6URL key for specified store already exists Magento 2Category has not been created. URL key for specified store already existsProduct “Save and Duplicate” errorThe value specified in the URL Key field would generate a URL that already exists
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
when I have the category in product assign and saving category below error showing
The value specified in the URL Key field would generate a URL that
already exists.
To resolve this conflict, you can either change the
value of the URL Key field (located in the Search Engine Optimization
section) to a unique value or change the Request Path fields in all
locations listed below:
and my exception.log error log is
magento2 admin category url-rewrite magento2.2.4
|
show 3 more comments
when I have the category in product assign and saving category below error showing
The value specified in the URL Key field would generate a URL that
already exists.
To resolve this conflict, you can either change the
value of the URL Key field (located in the Search Engine Optimization
section) to a unique value or change the Request Path fields in all
locations listed below:
and my exception.log error log is
magento2 admin category url-rewrite magento2.2.4
You have duplicate URLs.
– vitoriodachef
Jun 21 at 9:07
@vitoriodachef but how can solve this issue
– Rakesh Donga
Jun 21 at 9:09
@vitoriodachef and exception.log isURL key for specified store already exists.
– Rakesh Donga
Jun 21 at 9:20
Wich magento version are you using?
– Chirag Patel
Jun 21 at 9:29
@ChiragPatel magento 2.2.4
– Rakesh Donga
Jun 21 at 9:29
|
show 3 more comments
when I have the category in product assign and saving category below error showing
The value specified in the URL Key field would generate a URL that
already exists.
To resolve this conflict, you can either change the
value of the URL Key field (located in the Search Engine Optimization
section) to a unique value or change the Request Path fields in all
locations listed below:
and my exception.log error log is
magento2 admin category url-rewrite magento2.2.4
when I have the category in product assign and saving category below error showing
The value specified in the URL Key field would generate a URL that
already exists.
To resolve this conflict, you can either change the
value of the URL Key field (located in the Search Engine Optimization
section) to a unique value or change the Request Path fields in all
locations listed below:
and my exception.log error log is
magento2 admin category url-rewrite magento2.2.4
magento2 admin category url-rewrite magento2.2.4
edited Jun 21 at 9:51
Rakesh Donga
asked Jun 21 at 7:35
Rakesh DongaRakesh Donga
2,9456 silver badges21 bronze badges
2,9456 silver badges21 bronze badges
You have duplicate URLs.
– vitoriodachef
Jun 21 at 9:07
@vitoriodachef but how can solve this issue
– Rakesh Donga
Jun 21 at 9:09
@vitoriodachef and exception.log isURL key for specified store already exists.
– Rakesh Donga
Jun 21 at 9:20
Wich magento version are you using?
– Chirag Patel
Jun 21 at 9:29
@ChiragPatel magento 2.2.4
– Rakesh Donga
Jun 21 at 9:29
|
show 3 more comments
You have duplicate URLs.
– vitoriodachef
Jun 21 at 9:07
@vitoriodachef but how can solve this issue
– Rakesh Donga
Jun 21 at 9:09
@vitoriodachef and exception.log isURL key for specified store already exists.
– Rakesh Donga
Jun 21 at 9:20
Wich magento version are you using?
– Chirag Patel
Jun 21 at 9:29
@ChiragPatel magento 2.2.4
– Rakesh Donga
Jun 21 at 9:29
You have duplicate URLs.
– vitoriodachef
Jun 21 at 9:07
You have duplicate URLs.
– vitoriodachef
Jun 21 at 9:07
@vitoriodachef but how can solve this issue
– Rakesh Donga
Jun 21 at 9:09
@vitoriodachef but how can solve this issue
– Rakesh Donga
Jun 21 at 9:09
@vitoriodachef and exception.log is
URL key for specified store already exists.
– Rakesh Donga
Jun 21 at 9:20
@vitoriodachef and exception.log is
URL key for specified store already exists.
– Rakesh Donga
Jun 21 at 9:20
Wich magento version are you using?
– Chirag Patel
Jun 21 at 9:29
Wich magento version are you using?
– Chirag Patel
Jun 21 at 9:29
@ChiragPatel magento 2.2.4
– Rakesh Donga
Jun 21 at 9:29
@ChiragPatel magento 2.2.4
– Rakesh Donga
Jun 21 at 9:29
|
show 3 more comments
3 Answers
3
active
oldest
votes
Please override with below two files : module-catalog-url-rewrite/Model/Product/AnchorUrlRewriteGenerator.php (Line 58)
/**
* Generate list based on categories
*
* @param int $storeId
* @param Product $product
* @param ObjectRegistry $productCategories
* @return UrlRewrite[]
*/
public function generate($storeId, Product $product, ObjectRegistry $productCategories)
$urls = [];
foreach ($productCategories->getList() as $category)
$anchorCategoryIds = $category->getAnchorsAbove();
if ($anchorCategoryIds)
foreach ($anchorCategoryIds as $anchorCategoryId)
//Default: $anchorCategory = $this->categoryRepository->get($anchorCategoryId);
$anchorCategory = $this->categoryRepository->get($anchorCategoryId, $storeId);
$urls[] = $this->urlRewriteFactory->create()
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
->setEntityId($product->getId())
->setRequestPath(
$this->urlPathGenerator->getUrlPathWithSuffix(
$product,
$storeId,
$anchorCategory
)
)
->setTargetPath(
$this->urlPathGenerator->getCanonicalUrlPath(
$product,
$anchorCategory
)
)
->setStoreId($storeId)
->setMetadata(['category_id' => $anchorCategory->getId()]);
return $urls;
step2 : module-catalog-url-rewrite/Model/ProductUrlRewriteGenerator.php (Line 146)
/**
* Generate list of urls for global scope
*
* @param MagentoFrameworkDataCollection $productCategories
*
* @return MagentoUrlRewriteServiceV1DataUrlRewrite[]
*/
protected function generateForGlobalScope($productCategories)
$urls = [];
$productId = $this->product->getEntityId();
foreach ($this->product->getStoreIds() as $id)
if (!$this->isGlobalScope($id)
&& !$this->storeViewService->doesEntityHaveOverriddenUrlKeyForStore($id, $productId, Product::ENTITY)
)
// Default: $urls = array_merge($urls, $this->generateForSpecificStoreView($id, $productCategories));
// before loading the category collection by looping it, clone it and set the correct store id,
// so we get the correct url_path & url_key for that specific store id
$storeSpecificProductCategories = clone $productCategories;
$storeSpecificProductCategories->setStoreId($id);
$urls = array_merge($urls, $this->generateForSpecificStoreView($id, $storeSpecificProductCategories));
return $urls;
please your code i have dont understand because your code in many <br> <p> available
– Rakesh Donga
Jun 21 at 9:34
check now, its code editor issue.
– Anas Mansuri
Jun 21 at 9:37
thanks ok let me check
– Rakesh Donga
Jun 21 at 9:41
not working for me
– Rakesh Donga
Jun 21 at 9:49
than please truncate url_rewrite table, than execute normal command which we are using.
– Anas Mansuri
Jun 21 at 9:52
|
show 3 more comments
1 Run the following SQL queries from the command line or phpMyAdmin,
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE url_rewrite;
SET FOREIGN_KEY_CHECKS = 1;
2 Within your backend, navigate to Products > Catalog.
3.Clear any and all filters, select all products (drop down menu option Select All).
4 Select the Update Attributes action from the Actions dropdown menu.
5 Under Products Information, click the Websites tab.
6 Under the Add Product to Websites section, check the box for Main Website (and
any other sites you may have)
7 Click Save.
8 Navigate to Products > Categores.
9 For each category you want to have a new URL key written, select it, update the URL key, ensure that the Create Permanent Redirect for Old URL checkbox is checked.
10 Click Save.
add a comment |
There are so may issue is already reported on stack & GitHub and other community. and there are so many solutions for that and which one is correct it is to difficult choosing the right one. but I see one issue is reported on GitHub which one help to you I think. https://github.com/magento/magento2/issues/7298
This issue occurring due to duplicate entry on the database table url_rewrite
, so there is only one way to resolve this issue you need to empty the table and regenerate the URL. so I have checked and found one answer which one usefull to me which I shared below.
Note: Take database backup before doing below opration.
Remove the duplication data when saving category. This data is throw in method doReplace($urls) in vendormagentomodule-url-rewriteModelStorageDbStorage.php
file.
protected function doReplace($urls)
foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData)
$urlData[UrlRewrite::ENTITY_TYPE] = $type;
$this->deleteByData($urlData);
$data = [];
foreach ($urls as $url)
$data[] = $url->toArray();
$this->insertMultiple($data);
I found out $data variable has a duplicate record. If you want this method to work without any errors. Rewrite this method above to below one.
protected function doReplace($urls)
foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData)
$urlData[UrlRewrite::ENTITY_TYPE] = $type;
$this->deleteByData($urlData);
$data = [];
$storeId_requestPaths = [];
foreach ($urls as $url)
$storeId = $url->getStoreId();
$requestPath = $url->getRequestPath();
// Skip if is exist in the database
$sql = "SELECT * FROM url_rewrite where store_id = $storeId and request_path = '$requestPath'";
$exists = $this->connection->fetchOne($sql);
if ($exists) continue;
$storeId_requestPaths[] = $storeId . '-' . $requestPath;
$data[] = $url->toArray();
// Remove duplication data;
$n = count($storeId_requestPaths);
for ($i = 0; $i < $n - 1; $i++)
for ($j = $i + 1; $j < $n; $j++)
if ($storeId_requestPaths[$i] == $storeId_requestPaths[$j])
unset($data[$j]);
$this->insertMultiple($data);
Taje refrance from Magento 2 Duplicate Product URLs Problem And "URL key for specified store already exists." cannot save category #7298
I hope it helps!
you are right @Chirag patel but default function is like : prntscr.com/o4sibb
– Rakesh Donga
Jun 21 at 10:12
There might be different code in function because of the different Magento version. so you have debugged this code and I have shared logicRemove duplication data;
try this
– Chirag Patel
Jun 21 at 10:16
Just print$data
variable of your function and check what's going wrong.
– Chirag Patel
Jun 21 at 10:18
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f279123%2fmagento-2-2-4-the-value-specified-in-the-url-key-field-would-generate-a-url-that%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Please override with below two files : module-catalog-url-rewrite/Model/Product/AnchorUrlRewriteGenerator.php (Line 58)
/**
* Generate list based on categories
*
* @param int $storeId
* @param Product $product
* @param ObjectRegistry $productCategories
* @return UrlRewrite[]
*/
public function generate($storeId, Product $product, ObjectRegistry $productCategories)
$urls = [];
foreach ($productCategories->getList() as $category)
$anchorCategoryIds = $category->getAnchorsAbove();
if ($anchorCategoryIds)
foreach ($anchorCategoryIds as $anchorCategoryId)
//Default: $anchorCategory = $this->categoryRepository->get($anchorCategoryId);
$anchorCategory = $this->categoryRepository->get($anchorCategoryId, $storeId);
$urls[] = $this->urlRewriteFactory->create()
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
->setEntityId($product->getId())
->setRequestPath(
$this->urlPathGenerator->getUrlPathWithSuffix(
$product,
$storeId,
$anchorCategory
)
)
->setTargetPath(
$this->urlPathGenerator->getCanonicalUrlPath(
$product,
$anchorCategory
)
)
->setStoreId($storeId)
->setMetadata(['category_id' => $anchorCategory->getId()]);
return $urls;
step2 : module-catalog-url-rewrite/Model/ProductUrlRewriteGenerator.php (Line 146)
/**
* Generate list of urls for global scope
*
* @param MagentoFrameworkDataCollection $productCategories
*
* @return MagentoUrlRewriteServiceV1DataUrlRewrite[]
*/
protected function generateForGlobalScope($productCategories)
$urls = [];
$productId = $this->product->getEntityId();
foreach ($this->product->getStoreIds() as $id)
if (!$this->isGlobalScope($id)
&& !$this->storeViewService->doesEntityHaveOverriddenUrlKeyForStore($id, $productId, Product::ENTITY)
)
// Default: $urls = array_merge($urls, $this->generateForSpecificStoreView($id, $productCategories));
// before loading the category collection by looping it, clone it and set the correct store id,
// so we get the correct url_path & url_key for that specific store id
$storeSpecificProductCategories = clone $productCategories;
$storeSpecificProductCategories->setStoreId($id);
$urls = array_merge($urls, $this->generateForSpecificStoreView($id, $storeSpecificProductCategories));
return $urls;
please your code i have dont understand because your code in many <br> <p> available
– Rakesh Donga
Jun 21 at 9:34
check now, its code editor issue.
– Anas Mansuri
Jun 21 at 9:37
thanks ok let me check
– Rakesh Donga
Jun 21 at 9:41
not working for me
– Rakesh Donga
Jun 21 at 9:49
than please truncate url_rewrite table, than execute normal command which we are using.
– Anas Mansuri
Jun 21 at 9:52
|
show 3 more comments
Please override with below two files : module-catalog-url-rewrite/Model/Product/AnchorUrlRewriteGenerator.php (Line 58)
/**
* Generate list based on categories
*
* @param int $storeId
* @param Product $product
* @param ObjectRegistry $productCategories
* @return UrlRewrite[]
*/
public function generate($storeId, Product $product, ObjectRegistry $productCategories)
$urls = [];
foreach ($productCategories->getList() as $category)
$anchorCategoryIds = $category->getAnchorsAbove();
if ($anchorCategoryIds)
foreach ($anchorCategoryIds as $anchorCategoryId)
//Default: $anchorCategory = $this->categoryRepository->get($anchorCategoryId);
$anchorCategory = $this->categoryRepository->get($anchorCategoryId, $storeId);
$urls[] = $this->urlRewriteFactory->create()
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
->setEntityId($product->getId())
->setRequestPath(
$this->urlPathGenerator->getUrlPathWithSuffix(
$product,
$storeId,
$anchorCategory
)
)
->setTargetPath(
$this->urlPathGenerator->getCanonicalUrlPath(
$product,
$anchorCategory
)
)
->setStoreId($storeId)
->setMetadata(['category_id' => $anchorCategory->getId()]);
return $urls;
step2 : module-catalog-url-rewrite/Model/ProductUrlRewriteGenerator.php (Line 146)
/**
* Generate list of urls for global scope
*
* @param MagentoFrameworkDataCollection $productCategories
*
* @return MagentoUrlRewriteServiceV1DataUrlRewrite[]
*/
protected function generateForGlobalScope($productCategories)
$urls = [];
$productId = $this->product->getEntityId();
foreach ($this->product->getStoreIds() as $id)
if (!$this->isGlobalScope($id)
&& !$this->storeViewService->doesEntityHaveOverriddenUrlKeyForStore($id, $productId, Product::ENTITY)
)
// Default: $urls = array_merge($urls, $this->generateForSpecificStoreView($id, $productCategories));
// before loading the category collection by looping it, clone it and set the correct store id,
// so we get the correct url_path & url_key for that specific store id
$storeSpecificProductCategories = clone $productCategories;
$storeSpecificProductCategories->setStoreId($id);
$urls = array_merge($urls, $this->generateForSpecificStoreView($id, $storeSpecificProductCategories));
return $urls;
please your code i have dont understand because your code in many <br> <p> available
– Rakesh Donga
Jun 21 at 9:34
check now, its code editor issue.
– Anas Mansuri
Jun 21 at 9:37
thanks ok let me check
– Rakesh Donga
Jun 21 at 9:41
not working for me
– Rakesh Donga
Jun 21 at 9:49
than please truncate url_rewrite table, than execute normal command which we are using.
– Anas Mansuri
Jun 21 at 9:52
|
show 3 more comments
Please override with below two files : module-catalog-url-rewrite/Model/Product/AnchorUrlRewriteGenerator.php (Line 58)
/**
* Generate list based on categories
*
* @param int $storeId
* @param Product $product
* @param ObjectRegistry $productCategories
* @return UrlRewrite[]
*/
public function generate($storeId, Product $product, ObjectRegistry $productCategories)
$urls = [];
foreach ($productCategories->getList() as $category)
$anchorCategoryIds = $category->getAnchorsAbove();
if ($anchorCategoryIds)
foreach ($anchorCategoryIds as $anchorCategoryId)
//Default: $anchorCategory = $this->categoryRepository->get($anchorCategoryId);
$anchorCategory = $this->categoryRepository->get($anchorCategoryId, $storeId);
$urls[] = $this->urlRewriteFactory->create()
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
->setEntityId($product->getId())
->setRequestPath(
$this->urlPathGenerator->getUrlPathWithSuffix(
$product,
$storeId,
$anchorCategory
)
)
->setTargetPath(
$this->urlPathGenerator->getCanonicalUrlPath(
$product,
$anchorCategory
)
)
->setStoreId($storeId)
->setMetadata(['category_id' => $anchorCategory->getId()]);
return $urls;
step2 : module-catalog-url-rewrite/Model/ProductUrlRewriteGenerator.php (Line 146)
/**
* Generate list of urls for global scope
*
* @param MagentoFrameworkDataCollection $productCategories
*
* @return MagentoUrlRewriteServiceV1DataUrlRewrite[]
*/
protected function generateForGlobalScope($productCategories)
$urls = [];
$productId = $this->product->getEntityId();
foreach ($this->product->getStoreIds() as $id)
if (!$this->isGlobalScope($id)
&& !$this->storeViewService->doesEntityHaveOverriddenUrlKeyForStore($id, $productId, Product::ENTITY)
)
// Default: $urls = array_merge($urls, $this->generateForSpecificStoreView($id, $productCategories));
// before loading the category collection by looping it, clone it and set the correct store id,
// so we get the correct url_path & url_key for that specific store id
$storeSpecificProductCategories = clone $productCategories;
$storeSpecificProductCategories->setStoreId($id);
$urls = array_merge($urls, $this->generateForSpecificStoreView($id, $storeSpecificProductCategories));
return $urls;
Please override with below two files : module-catalog-url-rewrite/Model/Product/AnchorUrlRewriteGenerator.php (Line 58)
/**
* Generate list based on categories
*
* @param int $storeId
* @param Product $product
* @param ObjectRegistry $productCategories
* @return UrlRewrite[]
*/
public function generate($storeId, Product $product, ObjectRegistry $productCategories)
$urls = [];
foreach ($productCategories->getList() as $category)
$anchorCategoryIds = $category->getAnchorsAbove();
if ($anchorCategoryIds)
foreach ($anchorCategoryIds as $anchorCategoryId)
//Default: $anchorCategory = $this->categoryRepository->get($anchorCategoryId);
$anchorCategory = $this->categoryRepository->get($anchorCategoryId, $storeId);
$urls[] = $this->urlRewriteFactory->create()
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
->setEntityId($product->getId())
->setRequestPath(
$this->urlPathGenerator->getUrlPathWithSuffix(
$product,
$storeId,
$anchorCategory
)
)
->setTargetPath(
$this->urlPathGenerator->getCanonicalUrlPath(
$product,
$anchorCategory
)
)
->setStoreId($storeId)
->setMetadata(['category_id' => $anchorCategory->getId()]);
return $urls;
step2 : module-catalog-url-rewrite/Model/ProductUrlRewriteGenerator.php (Line 146)
/**
* Generate list of urls for global scope
*
* @param MagentoFrameworkDataCollection $productCategories
*
* @return MagentoUrlRewriteServiceV1DataUrlRewrite[]
*/
protected function generateForGlobalScope($productCategories)
$urls = [];
$productId = $this->product->getEntityId();
foreach ($this->product->getStoreIds() as $id)
if (!$this->isGlobalScope($id)
&& !$this->storeViewService->doesEntityHaveOverriddenUrlKeyForStore($id, $productId, Product::ENTITY)
)
// Default: $urls = array_merge($urls, $this->generateForSpecificStoreView($id, $productCategories));
// before loading the category collection by looping it, clone it and set the correct store id,
// so we get the correct url_path & url_key for that specific store id
$storeSpecificProductCategories = clone $productCategories;
$storeSpecificProductCategories->setStoreId($id);
$urls = array_merge($urls, $this->generateForSpecificStoreView($id, $storeSpecificProductCategories));
return $urls;
edited Jun 21 at 9:37
answered Jun 21 at 9:33
Anas MansuriAnas Mansuri
57515 bronze badges
57515 bronze badges
please your code i have dont understand because your code in many <br> <p> available
– Rakesh Donga
Jun 21 at 9:34
check now, its code editor issue.
– Anas Mansuri
Jun 21 at 9:37
thanks ok let me check
– Rakesh Donga
Jun 21 at 9:41
not working for me
– Rakesh Donga
Jun 21 at 9:49
than please truncate url_rewrite table, than execute normal command which we are using.
– Anas Mansuri
Jun 21 at 9:52
|
show 3 more comments
please your code i have dont understand because your code in many <br> <p> available
– Rakesh Donga
Jun 21 at 9:34
check now, its code editor issue.
– Anas Mansuri
Jun 21 at 9:37
thanks ok let me check
– Rakesh Donga
Jun 21 at 9:41
not working for me
– Rakesh Donga
Jun 21 at 9:49
than please truncate url_rewrite table, than execute normal command which we are using.
– Anas Mansuri
Jun 21 at 9:52
please your code i have dont understand because your code in many <br> <p> available
– Rakesh Donga
Jun 21 at 9:34
please your code i have dont understand because your code in many <br> <p> available
– Rakesh Donga
Jun 21 at 9:34
check now, its code editor issue.
– Anas Mansuri
Jun 21 at 9:37
check now, its code editor issue.
– Anas Mansuri
Jun 21 at 9:37
thanks ok let me check
– Rakesh Donga
Jun 21 at 9:41
thanks ok let me check
– Rakesh Donga
Jun 21 at 9:41
not working for me
– Rakesh Donga
Jun 21 at 9:49
not working for me
– Rakesh Donga
Jun 21 at 9:49
than please truncate url_rewrite table, than execute normal command which we are using.
– Anas Mansuri
Jun 21 at 9:52
than please truncate url_rewrite table, than execute normal command which we are using.
– Anas Mansuri
Jun 21 at 9:52
|
show 3 more comments
1 Run the following SQL queries from the command line or phpMyAdmin,
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE url_rewrite;
SET FOREIGN_KEY_CHECKS = 1;
2 Within your backend, navigate to Products > Catalog.
3.Clear any and all filters, select all products (drop down menu option Select All).
4 Select the Update Attributes action from the Actions dropdown menu.
5 Under Products Information, click the Websites tab.
6 Under the Add Product to Websites section, check the box for Main Website (and
any other sites you may have)
7 Click Save.
8 Navigate to Products > Categores.
9 For each category you want to have a new URL key written, select it, update the URL key, ensure that the Create Permanent Redirect for Old URL checkbox is checked.
10 Click Save.
add a comment |
1 Run the following SQL queries from the command line or phpMyAdmin,
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE url_rewrite;
SET FOREIGN_KEY_CHECKS = 1;
2 Within your backend, navigate to Products > Catalog.
3.Clear any and all filters, select all products (drop down menu option Select All).
4 Select the Update Attributes action from the Actions dropdown menu.
5 Under Products Information, click the Websites tab.
6 Under the Add Product to Websites section, check the box for Main Website (and
any other sites you may have)
7 Click Save.
8 Navigate to Products > Categores.
9 For each category you want to have a new URL key written, select it, update the URL key, ensure that the Create Permanent Redirect for Old URL checkbox is checked.
10 Click Save.
add a comment |
1 Run the following SQL queries from the command line or phpMyAdmin,
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE url_rewrite;
SET FOREIGN_KEY_CHECKS = 1;
2 Within your backend, navigate to Products > Catalog.
3.Clear any and all filters, select all products (drop down menu option Select All).
4 Select the Update Attributes action from the Actions dropdown menu.
5 Under Products Information, click the Websites tab.
6 Under the Add Product to Websites section, check the box for Main Website (and
any other sites you may have)
7 Click Save.
8 Navigate to Products > Categores.
9 For each category you want to have a new URL key written, select it, update the URL key, ensure that the Create Permanent Redirect for Old URL checkbox is checked.
10 Click Save.
1 Run the following SQL queries from the command line or phpMyAdmin,
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE url_rewrite;
SET FOREIGN_KEY_CHECKS = 1;
2 Within your backend, navigate to Products > Catalog.
3.Clear any and all filters, select all products (drop down menu option Select All).
4 Select the Update Attributes action from the Actions dropdown menu.
5 Under Products Information, click the Websites tab.
6 Under the Add Product to Websites section, check the box for Main Website (and
any other sites you may have)
7 Click Save.
8 Navigate to Products > Categores.
9 For each category you want to have a new URL key written, select it, update the URL key, ensure that the Create Permanent Redirect for Old URL checkbox is checked.
10 Click Save.
answered Jun 21 at 10:01
Anas MansuriAnas Mansuri
57515 bronze badges
57515 bronze badges
add a comment |
add a comment |
There are so may issue is already reported on stack & GitHub and other community. and there are so many solutions for that and which one is correct it is to difficult choosing the right one. but I see one issue is reported on GitHub which one help to you I think. https://github.com/magento/magento2/issues/7298
This issue occurring due to duplicate entry on the database table url_rewrite
, so there is only one way to resolve this issue you need to empty the table and regenerate the URL. so I have checked and found one answer which one usefull to me which I shared below.
Note: Take database backup before doing below opration.
Remove the duplication data when saving category. This data is throw in method doReplace($urls) in vendormagentomodule-url-rewriteModelStorageDbStorage.php
file.
protected function doReplace($urls)
foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData)
$urlData[UrlRewrite::ENTITY_TYPE] = $type;
$this->deleteByData($urlData);
$data = [];
foreach ($urls as $url)
$data[] = $url->toArray();
$this->insertMultiple($data);
I found out $data variable has a duplicate record. If you want this method to work without any errors. Rewrite this method above to below one.
protected function doReplace($urls)
foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData)
$urlData[UrlRewrite::ENTITY_TYPE] = $type;
$this->deleteByData($urlData);
$data = [];
$storeId_requestPaths = [];
foreach ($urls as $url)
$storeId = $url->getStoreId();
$requestPath = $url->getRequestPath();
// Skip if is exist in the database
$sql = "SELECT * FROM url_rewrite where store_id = $storeId and request_path = '$requestPath'";
$exists = $this->connection->fetchOne($sql);
if ($exists) continue;
$storeId_requestPaths[] = $storeId . '-' . $requestPath;
$data[] = $url->toArray();
// Remove duplication data;
$n = count($storeId_requestPaths);
for ($i = 0; $i < $n - 1; $i++)
for ($j = $i + 1; $j < $n; $j++)
if ($storeId_requestPaths[$i] == $storeId_requestPaths[$j])
unset($data[$j]);
$this->insertMultiple($data);
Taje refrance from Magento 2 Duplicate Product URLs Problem And "URL key for specified store already exists." cannot save category #7298
I hope it helps!
you are right @Chirag patel but default function is like : prntscr.com/o4sibb
– Rakesh Donga
Jun 21 at 10:12
There might be different code in function because of the different Magento version. so you have debugged this code and I have shared logicRemove duplication data;
try this
– Chirag Patel
Jun 21 at 10:16
Just print$data
variable of your function and check what's going wrong.
– Chirag Patel
Jun 21 at 10:18
add a comment |
There are so may issue is already reported on stack & GitHub and other community. and there are so many solutions for that and which one is correct it is to difficult choosing the right one. but I see one issue is reported on GitHub which one help to you I think. https://github.com/magento/magento2/issues/7298
This issue occurring due to duplicate entry on the database table url_rewrite
, so there is only one way to resolve this issue you need to empty the table and regenerate the URL. so I have checked and found one answer which one usefull to me which I shared below.
Note: Take database backup before doing below opration.
Remove the duplication data when saving category. This data is throw in method doReplace($urls) in vendormagentomodule-url-rewriteModelStorageDbStorage.php
file.
protected function doReplace($urls)
foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData)
$urlData[UrlRewrite::ENTITY_TYPE] = $type;
$this->deleteByData($urlData);
$data = [];
foreach ($urls as $url)
$data[] = $url->toArray();
$this->insertMultiple($data);
I found out $data variable has a duplicate record. If you want this method to work without any errors. Rewrite this method above to below one.
protected function doReplace($urls)
foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData)
$urlData[UrlRewrite::ENTITY_TYPE] = $type;
$this->deleteByData($urlData);
$data = [];
$storeId_requestPaths = [];
foreach ($urls as $url)
$storeId = $url->getStoreId();
$requestPath = $url->getRequestPath();
// Skip if is exist in the database
$sql = "SELECT * FROM url_rewrite where store_id = $storeId and request_path = '$requestPath'";
$exists = $this->connection->fetchOne($sql);
if ($exists) continue;
$storeId_requestPaths[] = $storeId . '-' . $requestPath;
$data[] = $url->toArray();
// Remove duplication data;
$n = count($storeId_requestPaths);
for ($i = 0; $i < $n - 1; $i++)
for ($j = $i + 1; $j < $n; $j++)
if ($storeId_requestPaths[$i] == $storeId_requestPaths[$j])
unset($data[$j]);
$this->insertMultiple($data);
Taje refrance from Magento 2 Duplicate Product URLs Problem And "URL key for specified store already exists." cannot save category #7298
I hope it helps!
you are right @Chirag patel but default function is like : prntscr.com/o4sibb
– Rakesh Donga
Jun 21 at 10:12
There might be different code in function because of the different Magento version. so you have debugged this code and I have shared logicRemove duplication data;
try this
– Chirag Patel
Jun 21 at 10:16
Just print$data
variable of your function and check what's going wrong.
– Chirag Patel
Jun 21 at 10:18
add a comment |
There are so may issue is already reported on stack & GitHub and other community. and there are so many solutions for that and which one is correct it is to difficult choosing the right one. but I see one issue is reported on GitHub which one help to you I think. https://github.com/magento/magento2/issues/7298
This issue occurring due to duplicate entry on the database table url_rewrite
, so there is only one way to resolve this issue you need to empty the table and regenerate the URL. so I have checked and found one answer which one usefull to me which I shared below.
Note: Take database backup before doing below opration.
Remove the duplication data when saving category. This data is throw in method doReplace($urls) in vendormagentomodule-url-rewriteModelStorageDbStorage.php
file.
protected function doReplace($urls)
foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData)
$urlData[UrlRewrite::ENTITY_TYPE] = $type;
$this->deleteByData($urlData);
$data = [];
foreach ($urls as $url)
$data[] = $url->toArray();
$this->insertMultiple($data);
I found out $data variable has a duplicate record. If you want this method to work without any errors. Rewrite this method above to below one.
protected function doReplace($urls)
foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData)
$urlData[UrlRewrite::ENTITY_TYPE] = $type;
$this->deleteByData($urlData);
$data = [];
$storeId_requestPaths = [];
foreach ($urls as $url)
$storeId = $url->getStoreId();
$requestPath = $url->getRequestPath();
// Skip if is exist in the database
$sql = "SELECT * FROM url_rewrite where store_id = $storeId and request_path = '$requestPath'";
$exists = $this->connection->fetchOne($sql);
if ($exists) continue;
$storeId_requestPaths[] = $storeId . '-' . $requestPath;
$data[] = $url->toArray();
// Remove duplication data;
$n = count($storeId_requestPaths);
for ($i = 0; $i < $n - 1; $i++)
for ($j = $i + 1; $j < $n; $j++)
if ($storeId_requestPaths[$i] == $storeId_requestPaths[$j])
unset($data[$j]);
$this->insertMultiple($data);
Taje refrance from Magento 2 Duplicate Product URLs Problem And "URL key for specified store already exists." cannot save category #7298
I hope it helps!
There are so may issue is already reported on stack & GitHub and other community. and there are so many solutions for that and which one is correct it is to difficult choosing the right one. but I see one issue is reported on GitHub which one help to you I think. https://github.com/magento/magento2/issues/7298
This issue occurring due to duplicate entry on the database table url_rewrite
, so there is only one way to resolve this issue you need to empty the table and regenerate the URL. so I have checked and found one answer which one usefull to me which I shared below.
Note: Take database backup before doing below opration.
Remove the duplication data when saving category. This data is throw in method doReplace($urls) in vendormagentomodule-url-rewriteModelStorageDbStorage.php
file.
protected function doReplace($urls)
foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData)
$urlData[UrlRewrite::ENTITY_TYPE] = $type;
$this->deleteByData($urlData);
$data = [];
foreach ($urls as $url)
$data[] = $url->toArray();
$this->insertMultiple($data);
I found out $data variable has a duplicate record. If you want this method to work without any errors. Rewrite this method above to below one.
protected function doReplace($urls)
foreach ($this->createFilterDataBasedOnUrls($urls) as $type => $urlData)
$urlData[UrlRewrite::ENTITY_TYPE] = $type;
$this->deleteByData($urlData);
$data = [];
$storeId_requestPaths = [];
foreach ($urls as $url)
$storeId = $url->getStoreId();
$requestPath = $url->getRequestPath();
// Skip if is exist in the database
$sql = "SELECT * FROM url_rewrite where store_id = $storeId and request_path = '$requestPath'";
$exists = $this->connection->fetchOne($sql);
if ($exists) continue;
$storeId_requestPaths[] = $storeId . '-' . $requestPath;
$data[] = $url->toArray();
// Remove duplication data;
$n = count($storeId_requestPaths);
for ($i = 0; $i < $n - 1; $i++)
for ($j = $i + 1; $j < $n; $j++)
if ($storeId_requestPaths[$i] == $storeId_requestPaths[$j])
unset($data[$j]);
$this->insertMultiple($data);
Taje refrance from Magento 2 Duplicate Product URLs Problem And "URL key for specified store already exists." cannot save category #7298
I hope it helps!
edited Jun 21 at 10:13
answered Jun 21 at 10:09
Chirag PatelChirag Patel
3,6186 silver badges28 bronze badges
3,6186 silver badges28 bronze badges
you are right @Chirag patel but default function is like : prntscr.com/o4sibb
– Rakesh Donga
Jun 21 at 10:12
There might be different code in function because of the different Magento version. so you have debugged this code and I have shared logicRemove duplication data;
try this
– Chirag Patel
Jun 21 at 10:16
Just print$data
variable of your function and check what's going wrong.
– Chirag Patel
Jun 21 at 10:18
add a comment |
you are right @Chirag patel but default function is like : prntscr.com/o4sibb
– Rakesh Donga
Jun 21 at 10:12
There might be different code in function because of the different Magento version. so you have debugged this code and I have shared logicRemove duplication data;
try this
– Chirag Patel
Jun 21 at 10:16
Just print$data
variable of your function and check what's going wrong.
– Chirag Patel
Jun 21 at 10:18
you are right @Chirag patel but default function is like : prntscr.com/o4sibb
– Rakesh Donga
Jun 21 at 10:12
you are right @Chirag patel but default function is like : prntscr.com/o4sibb
– Rakesh Donga
Jun 21 at 10:12
There might be different code in function because of the different Magento version. so you have debugged this code and I have shared logic
Remove duplication data;
try this– Chirag Patel
Jun 21 at 10:16
There might be different code in function because of the different Magento version. so you have debugged this code and I have shared logic
Remove duplication data;
try this– Chirag Patel
Jun 21 at 10:16
Just print
$data
variable of your function and check what's going wrong.– Chirag Patel
Jun 21 at 10:18
Just print
$data
variable of your function and check what's going wrong.– Chirag Patel
Jun 21 at 10:18
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f279123%2fmagento-2-2-4-the-value-specified-in-the-url-key-field-would-generate-a-url-that%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
You have duplicate URLs.
– vitoriodachef
Jun 21 at 9:07
@vitoriodachef but how can solve this issue
– Rakesh Donga
Jun 21 at 9:09
@vitoriodachef and exception.log is
URL key for specified store already exists.
– Rakesh Donga
Jun 21 at 9:20
Wich magento version are you using?
– Chirag Patel
Jun 21 at 9:29
@ChiragPatel magento 2.2.4
– Rakesh Donga
Jun 21 at 9:29