Magento – a Taxonothe attribute

attributescategorycategory-treeextensionsproduct

I was asked to add a taxonomy attribute. I now that could be thought that it is way to broad so I'll try to do my best to lay out everything as this question evolves. The demand from them is that they don't want the categories or tags to be used for this as they are using this already. What they want is to basically have the category tree that is in the product edit page tab to be reproduced with custom data in a new tab called "taxonomies". I have bee trying to plot out how to best approach this but I'm running in circles here.

The conditions are:

  1. The values are to be searchable
  2. The existing category system is not to be replaced (in other words a solution is not "why not use the categories?")
  3. It must have hierarchy
  4. if possible have a url for the taxonomy value (yeah I know)

Basically I have just been asked to reproduce the category system. :\ I have been reading around and found many examples of setting the category tree selector in extensions, Add Category tree in custom extension for example. None of the examples are leading me to what the solution should look like.

Here are possible solutions I have been running down.

  1. A new extension that sets a EAV attribute maybe?
  2. try to copy the whole category system under a new name scope?
  3. ???

I'm not really sure where the best path is but it I know it'll be a long one.

The short of this is, how can I do what wordpress does I guess. This is where the boss people have picked up the idea and are steadfast on "this is a must".

Best Answer

If it's too complex, than fake the feature.

1) You could try to have a multi-select attribute. The options in admin should be padded. Padding spaces are levels to that node. Like categories in multi-select but with +1 space before childs categories. Or you can have a custom renderer in admin for that attribute which is not hard to make. On frontend you can render in layer navigation all values in a html/js tree. Values can be expandable and selectable. The values of this multiselect are searchable. If you want urls for this attribute have an extension that creates attribute_value.html pages like 'Shop by Brand' extensions. It will be a hassle to customize it for your exact needs. A variation of the attribute solution is to use a custom source table. In this table you can have a hierarchy of rows defined as you see fit.

2) A real solution would be to define a whole new module with a new EAV entity. Try to use Varien_Data_Tree. Plenty of examples in Category module. You'd not have to duplicate Category module entirely. This implementation is very complex in my opinion. It is a Magento developer nightmare - mine at least.

3) A simpler variation of 3) is to have a new entity (not EAV). Have it like the classic way of creating categories in sql tables. (parent_id, child_id) table or a column with parents of the current row. Products will be linked through an additional table with the taxonomy entity (taxonomy_id, product_id). Do use indexers and do cache most of the blocks for this taxonomy entity. Their data won't change too often.

4) I don't see customers using two trees that are in fact 2 different ways of reaching a product. The ones that don't know what to look for will have a harder time navigating in both trees. I guess you can have 2 'main' categories. One will be used in navigation and the other for 'taxonomy'. For all categories products ca be assigned. You'd have to make sure to use in navigation and layered navigation only the categories from the first 'main category'.

People that take decisions lose touch with reality now and than. Magento is a complex eCommerce platform. Merchants tend to bring their complex business logic in customers minds. Magento is a complex eCommerce platform. Implementing an extremely complex feature takes time and resources. A successful Magento store is a fast one and easy to use. If you approach this matter they'll come to their senses. Look for a different feature that addresses the main concern and that would replace the original feature (taxonomy tree).

Related Topic