Magento2:更新类别,URL 密钥已存在错误

问题描述 投票:0回答:5

我创建了一个新类别,目前在导航菜单中不可见。
我通过代码及其工作原理向其中添加产品。

现在我正在编辑要在导航菜单中显示的类别,它会抛出错误,因为“指定商店的 URL 键已存在”。

我尝试:
未分配的产品,引发相同的错误。
更改了 URL、留空或更改了 URL 值。

请告诉我。

admin updates categories magento2
5个回答
0
投票

清除数据库表url_rewrite但是!仅适用于类别。否则会弄乱 CMS 页面链接。

执行此操作后,错误应该消失了。


0
投票

1)从“url_rewrite”中删除entity_type为“category”的记录

2)运行

php bin/magento php bin/magento indexer:reindex


0
投票

1) 进入数据库

2)搜索

url_rewrite
,“类别”
entity_type
被删除

3)最后运行这个命令,

php bin/magento indexer:reindex


0
投票

我也有同样的问题。 暂时将类别 URL 重命名为其他名称,清除缓存并将其重命名为您之前的原始 URL。


0
投票

检查现有的 URL 密钥:

Navigate to Catalog > Categories in the Magento admin panel.

Review the URL keys of existing categories to ensure the one you want to use isn’t already in use.

更改网址键:

If the URL key is in use, modify your desired category’s URL key to a unique value. You can add a suffix or prefix to differentiate it.

重新索引数据:

After changing the URL key, go to System > Index Management and reindex the data. This can help in clearing any cache and ensuring the changes are recognized.

清除缓存:

Clear the Magento cache by navigating to System > Cache Management and clicking on “Flush Magento Cache” and “Flush Cache Storage.”

数据库检查(如果需要):

If you have access to the database, you can run a query to check existing URL keys:

**sql**

SELECT * FROM catalog_category_entity_varchar WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'url_key') AND value = '**your-desired-url-key**';

Replace '**your-desired-url-key**' with the key you want to use.

检查 URL 重写:

Check the url_rewrite table in the database to see if the URL key is associated with any old rewrites that might be causing conflicts.

禁用 URL 密钥生成:

In some cases, disabling the automatic URL key generation might help. You can do this by setting the URL key to empty and saving, then changing it back to your desired key.

日志和调试:

Check Magento logs in var/log for any additional error messages that might provide more insight into the issue.
© www.soinside.com 2019 - 2024. All rights reserved.