Monday, February 14, 2011

Magento category management flaw (bug)

Category is a typical hierarchical data structure. Two options of Managing Hierarchical Data in relational database are Adjacency List Model and Nested Set Model. Here is a very excellent article about this topic:

Theoretically, Magento allows a user to create unlimited level of categories. Magento uses Adjacency List Model to manage hierarchical data. To overcome the disadvantages of Adjacency List Model, Magento's catalog_category_entity table includes these columns: depth, level, children_count, path.

As far as i can see, the flaw is caused by the column 'path'. 'path' is a varchar(255), it stores the path from the top level category to itself. For example, the current category id is 5. It is a sub category of 4, a sub category of 3, a sub category of 1. The path data of id 5 will be like "1/3/4/5". Problem occurs when the length of the path string exceeds 255. The new category won't be able to displayed correctly.

I think this is a minor issue cause most of the time we don't need to create such huge and deep level of categories, or do we?

No comments: