Jump to content

link two categories


diecov

Recommended Posts

Hello,

I am very new to prestashop.

I am working on the version 1.6.1.12 and I am trying to extend a category by adding a new reference to another category.

Basically I need to link two categories in a different way than the regular "parent-child".

 

I added a new field "related_category_id" (int) to the ps_category table on the DB, then I added the corresponding variable in the category object.

After that I would like to add a second "category treeview" just after the "parent category" one in the category admin form, to edit the related_category_id field. HERE COMES THE PAIN!

 

I tried extending the renderForm() function of the AdminCategoriesController by adding a  new array with " 'type'  => 'categories' " but it didn't work! I also tried to follow some tutorials found on the internet (like the one from this forum "Allow multiple category trees in backoffice form" started by shaktishakya on Jul 05 2014) with no results.

 

Can anyone point me to some information to understand how the generation of that form works and how to override the default behaviour or can provide some advices to solve this problem?

 

Sorry if my question is too basic...

 

Thank you very much!

 

Diego

Link to comment
Share on other sites

  • 2 weeks later...

Hi Scully, thank you for the answer!

I know that is a challenging requirements, that's the reason why I am asking for some experienced developer's help !  ;)

 

The reason why I am trying to accomplish this goal is that the customer has a huge number of products and a  very complicated category tree. 

They deal with spare parts and based on theyr needs, every product can be categorized in three different ways: by model , by part-type and by catalog.

For example the product X can be part of the model A and the model B, it is a part of the engine and the chassis, and can be listed into catalog 3.

 

My first attempt was to create a "normalized tree" so I put the model as first level category, then the catalog as second level (repeted for each model)  and finally the part-type as third level (repeted for each catalog and each model). Unfortunately the levels grew up because they introduced the versions for the models (model A version 1 and model A version 2) and the sub-part-type (chassis -> plastic covers and chassis-> glasses). This caused a 5 levels category trees; so If they have to insert a product that is linked to three different models, they need to check a lot of categories (many sub-part types per many part types, per many catalogs per many model versions etc...). That's a nightmare!!

 

What I wanted to do was to let them select just one (or more) model / model versions, one (or more) catalog and one (or more) type /subtype; then I could link the information together on the backend. The information would be "denormalized"...

 

I don't know if my explanation is clear, sorry  :wacko:

 

Diego

Link to comment
Share on other sites

The place to hook on would be the category class (Category.php). Furthermore you also needed to rewrite the backoffice category manager ( AdminCategoriesController.php ) to allow multiple connections between the categories and of course the tpl associated with that controller. And quite likle you needed to change the database structure for categories as well.

 

As with my experience it would be a HUGE effort and you might face many problems at several places where the category tree is resolved. It's even not handable to explain all in this forum.

Edited by Scully (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...