简体   繁体   English

magento url重写没用?

[英]magento url rewrite useless?

Two points I want to mention. 我要提两点。

First Point. 第一点。 I noticed a strange behavior, most probably a bug. 我注意到一种奇怪的行为,很可能是一个bug。 I configured a new clean instance of Magento (no other module, so from scratch) and an empty database. 我配置了一个新的Magento干净实例(没有其他模块,所以从头开始)和一个空数据库。 I created 3 categories below the root one. 我在根目录下创建了3个类别。 And 3 products, one in each category. 3个产品,每个类别一个。 Something like: 就像是:

Cat 1
+ Prod 1
Cat 2
+ Prod 2
Cat 3
+ Prod 3

If I change the order of the category so "Cat 3" is before "Cat 2" like this: 如果我更改类别的顺序,那么“Cat 3”就在“Cat 2”之前,如下所示:

Cat 1
+ Prod 1
Cat 3
+ Prod 3
Cat 2
+ Prod 2

I just need to drag and drop "Cat 3" above "cat 2" from the category management screen. 我只需要在类别管理屏幕上将“Cat 3”拖放到“cat 2”上方。 So the "order" number of cat2 and cat3 are actually exchanged. 所以cat2和cat3的“订单”号实际上是交换的。

BUT the url index process reindexes ALL products of ALL categories (URL REWRITE index)! 但url索引进程重新索引所有类别的所有产品(URL REWRITE索引)! I analyzed the SQL log, and it actually does an INSERT with every single product in the database. 我分析了SQL日志,它实际上对数据库中的每个产品进行了INSERT。 I see insert in core_url_rewrite for "Prod 1", "Prod 2" and "Prod 3". 我看到在core_url_rewrite中插入“Prod 1”,“Prod 2”和“Prod 3”。

This is a bug, because "Cat 3" keeps the same parent category, so: 1) there is no need to rewrite products within "Cat 3" (the product name didn 't change, the category name didn't change!!) 2) there is no need to rewrite products linked to other categories 这是一个错误,因为“Cat 3”保持相同的父类别,因此:1)不需要在“Cat 3”中重写产品(产品名称没有改变,类别名称没有改变!! )2)无需重写与其他类别相关的产品

Actually, by doing a select, I can see that the rows of the core_url_rewrite table are the same (for sure as no name changed! and no association between products and any categories above the products changed!) 实际上,通过选择,我可以看到core_url_rewrite表的行是相同的(确实没有更改名称!产品和产品之上的任何类别之间没有关联更改!)

Here is one SQL query that I see out of the log file wen I move the category: 这是我从日志文件中看到的一个SQL查询我移动类别:

        SQL: INSERT INTO `core_url_rewrite` (`store_id`,`category_id`,`product_id`,`id_path`,`request_path`,`target_path`,`is_system`) VALUES (?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE store_id = VALUES(`store_id`), category_id = VALUES(`category_id`), product_id = VALUES(`product_id`), id_path = VALUES(`id_path`), request_path = VALUES(`request_path`), target_path = VALUES(`target_path`), is_system = VALUES(`is_system`)
BIND: array (
  0 => '1',
  1 => NULL,
  2 => '4',
  3 => 'product/4',
  4 => 'testun.html',
  5 => 'catalog/product/view/id/4',
  6 => 1,
)
AFF: 0
TIME: 0.0005

Actually, the worse thing is, it does an insert of a row that already exist, so it actually does not insert anything. 实际上,更糟糕的是,它会插入已存在的行,因此它实际上不会插入任何内容。 The insert failed (you can see "AFF: 0" meaning nothing has been inserted) It is a waste of time to process each product for nothing, and try to insert something that might be already there!! 插入失败(您可以看到“AFF:0”表示没有插入任何内容)处理每个产品都是浪费时间,并尝试插入可能已经存在的东西!

Second points I found another bug/strange behavior. 第二点我发现了另一个错误/奇怪的行为。 If I have 2 products with the same name (it can happen), then the url key is the same (by default). 如果我有2个具有相同名称的产品(可能会发生),那么url键是相同的(默认情况下)。 BTW url key is also the same by default when you duplicate a product to create a new one. 复制产品以创建新产品时,BTW网址密钥默认也相同。

So The reindex process becomes crazy. 所以reindex过程变得疯狂。 eg, 2 products with the name "camera" will have the url rewrting like this: 例如,2个名为“camera”的产品将重新打包,如下所示:

camera-1.html
camera-2.html

I'm ok with this. 我很好。 BUT, if now I reindex everything, it becomes crazy. 但是,如果现在我重新索引一切,那就变得疯狂了。 it will change the url rewriting of those products (even if I didn't change anything related to those products). 它将改变这些产品的URL重写(即使我没有更改与这些产品相关的任何内容)。 it will update the 2 products like this: 它将更新这样的2个产品:

UPDATE camera-1.html  => camera-3.html 
UPDATE camera-2.html  => camera-4.html 

and insert redirection if the setting is enabled (so previous links are not lost), somethign like 并且如果启用了设置,则插入重定向(因此以前的链接不会丢失),有些像是

INSERT camera-1.html , camera-3.html ,RP
INSERT camera-2.html , camera-4.html , RP

RP options is about permanent redirect. RP选项是关于永久重定向。

So 2 useless updates and 2 useless Insert for nothing. 所以2无用的更新和2无用插入什么都没有。 If I reindex again, I wait the end, and reindex immediately, then Magento does 4 updates, 4 inserts etc. Why?? 如果我再次重新索引,我等待结束,立即重新索引,然后Magento做4次更新,4次插入等等。为什么? No change at all with any data between the reindex :-) 重新索引之间的任何数据都没有变化:-)

If you have 5 000 products with the same name (like I have), then it's 10 000 updates and 10 000 (real) insert for nothing... Size of core_url_rewrite increase again and again on a daily basis. 如果您有5 000个具有相同名称的产品(就像我有的那样),那么它的10 000个更新和10 000(真实)插入什么都没有... core_url_rewrite的大小每天都会一次又一次地增加。 Suration is extremely high Note: I have a good reason to have 5 000 products with exactly the same name :-) Whatever my reason this looks strange. Suration非常高注意:我有充分的理由让5 000种产品具有完全相同的名称:-)无论我的理由是什么,这看起来很奇怪。

Have you already checked this? 你已经检查了这个吗? Quite easy to check with a fresh installation of magento and log files enabled. 使用全新安装的magento和日志文件非常容易检查。

Last thing is , why do we need the core_url_rewrite table? 最后一件事是 ,为什么我们需要core_url_rewrite表? This is one of the main cause of performance issue with magento! 这是magento性能问题的主要原因之一!

4 lines of php code+htaccess url rewrite would do exactly the same job, no need of a DB Table for this (except for custom url rewrite or CMS page). 4行php代码+ htaccess url重写将完成相同的工作,不需要数据库表(除了自定义URL重写或CMS页面)。 one method to generate dynamically the url of a product (based on name and category if needed) and one to generate the url of a category. 一种动态生成产品网址的方法(根据需要根据名称和类别)和一种生成类别网址的方法。 then htaccess to redirect. 然后htaccess重定向。 you just need a keyword in the url to know whether it is a link to a product or a category, and its ID. 您只需要在网址中使用关键字即可知道它是指向产品或类别的链接及其ID。 something like: 就像是:

my-cat/camera-112-p.html

htacces URL rewrite detects it's a link to a product (because of -p.htm), it gets the product id out of the url (112) and redirect the user accordingly. htacces URL重写检测到它是产品的链接(因为-p.htm),它从url(112)获取产品ID并相应地重定向用户。 having the product ID might looks ugly or an issue with SEO, but I don't think so (not as bad as you can read). 拥有产品ID可能看起来很难看或SEO的问题,但我不这么认为(没有你能读到的那么糟糕)。 And it has to be balanced with the big benefit: 1) no huge table anymore 2) no need to reindex this table (this takes hours, like 8 hours, with a lot of magento website). 它必须与最大的好处相平衡:1)不再有大表2​​)无需重新索引这个表(这需要几个小时,比如8小时,有很多magento网站)。 This process can cause a lot of timeout issue, locking etc. 此过程可能会导致很多超时问题,锁定等。

at least this should be possible through an option (or a module). 至少这应该可以通过选项(或模块)。 Note also that you don't even need to care about permanent redirection, since the content (text) within the link does not matter! 另请注意,您甚至不需要关心永久重定向,因为链接中的内容(文本)无关紧要! Just the ID matters. 只是身份证很重要。

Does it exist? 它存在吗? if yes I will definetely buy it to say "bye-bye" to this complex messy mechanism (with bugs) 如果是的话,我会定义购买它来对这个复杂的混乱机制说“再见”(带有错误)

any feedback will be hight appreciated. 任何反馈意见都会受到高度赞赏。 (especially if you find any rational in the way magento behaves, taken into account the poor performance linked to use/manage this table, so the rationnal has to be highly appreciated :-) ) (特别是如果你发现magento的行为有任何理性,考虑到与使用/管理这个表相关的不良表现,所以必须高度赞赏理性:-))

thanks Rod 谢谢罗德

Point one and two seem to have been addressed see the notes for EE 1.13.0.2 (released today, CE 1.7 coming soon): http://www.magentocommerce.com/knowledge-base/entry/ee113-later-release-notes#prod-url-unique 第一点和第二点似乎已得到解决,请参阅EE 1.13.0.2的注释(今天发布,CE 1.7即将推出): http//www.magentocommerce.com/knowledge-base/entry/ee113-later-release-notes #PROD-URL唯一

But, it's worth addressing some of your points. 但是,值得解决一些问题。

  • Why do/did URL rewrites work this way? 为什么URL重写以这种方式工作? Because that's the way they worked - it's just how they were created/evolved, including the racing rewrite bug you noticed when two products have the same url_key . 因为这就是他们的工作方式 - 这就是他们创建/演变的方式,包括当两个产品具有相同的url_key时你注意到的赛车重写错误。
  • Based on a lot of benchmarking and experience, I can state that the core_url_rewrite table is not "the main cause of poor performance in Magento". 根据大量的基准测试和经验,我可以说core_url_rewrite不是 “Magento性能不佳的主要原因”。 The reindex process can suck though, no doubt. 毫无疑问,重新索引过程可能很糟糕。
  • The URL rewrite table is necessary for custom rewrites in general . 该URL改写表必要的,一般的自定义重写。 Suggesting that manipulation of server config files (eg Apache .htaccess ) to add rewrites fails to consider that Magento is an application which can be modified and extended without direct developer knowledge (eg by store owner). 建议操纵服务器配置文件(例如Apache .htaccess )以添加重写不能认为Magento是一个可以在没有直接开发人员知识的情况下进行修改和扩展的应用程序(例如,由店主)。
  • The suggestion to use a pretty-urls mod_rewrite pattern is not tenable for any shop concerned with SEO, and I assure you that the URL path is quite important to ranking/relevance. 使用pretty-urls mod_rewrite模式的建议对任何与SEO有关的商店都不合适,我向你保证,URL路径对于排名/相关性非常重要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM