Page 1 of 2

Product multiple relationship with a different Model

Posted: 05 Jul 2018, 17:33
by Nelson Martins
Hello,

I'm building an online store which will sell machine parts - these will be the products.
But I need to relate products (parts) with multiple machines to which those parts apply.
A product can relate to multiple machines.
So should I create a different Model to define a machine and then relate Product and Machine via some kind of HasMany relationship between them?
It would have to be possible to change the Product admin interface and create a way of creating those multiple associations.
What would be needed to do this? Is there a some easier way to acomplish this in Aimeos?

thanks!

Re: Product multiple relationship with a different Model

Posted: 06 Jul 2018, 11:28
by aimeos
Just a quick thought: Add your machines as category nodes that can have relationships to many machine parts, e.g.

- Root category
|- Production
|- Machine 1 -> part 1, part 2, part 3
|- Machine 2 -> part 4, part 3, part 5

You can add Texts, Images and as many machine parts (products) to your "Machine X" category and also add relationships to other domains (e.g. Suppliers, etc.)

Re: Product multiple relationship with a different Model

Posted: 06 Jul 2018, 12:35
by Nelson Martins
Hello,
thanks for your reply!

the thing is that a Machine has to be defined by this 3 fields:
- Brand (should be a taxonomy of terms)
- Series (text field)
- Model (text field)

We're talking about thousands of machine parts (products) associated with thousands of Machines (categories) ...
Even if there is a chance of having that kind of metadata on a category, would it make sense to have this kind of structure built into Categories?

Re: Product multiple relationship with a different Model

Posted: 06 Jul 2018, 14:02
by aimeos
I still think so. It doesn't matter how many parts (articles) you associate to a product (category). The only thing you should take care of is to avoid adding all your products (categories) below the root category node. This would be a lot data to load. Instead, group your products (leaf categories) in a category tree with at least two or more levels, e.g.

Root category
- Group 1
-- Machine 1
-- Machine 2
- Group 2
-- ...

or even

Root category
- Group 1
-- Sub-group 1
--- Machine 1
--- Machine 2
-- Sub-group 2
--- Machine 3
- Group 2
-- Sub-group 3
--- ...

The rest of your data can be added to your products (leaf categories) without problems.

Re: Product multiple relationship with a different Model

Posted: 10 Jul 2018, 08:26
by Nelson Martins
And would there be a way to add those Category fields (Brand, Series, Model) only to a specific categories branch (a root 'Machines' category, for instance, and its children), so as not to affect other categories with other purposes?

Re: Product multiple relationship with a different Model

Posted: 10 Jul 2018, 20:23
by aimeos
Yes, you have the root line of category items available in the template so you can inherit the data from parent categories if you want.

Re: Product multiple relationship with a different Model

Posted: 16 Jul 2018, 16:03
by Nelson Martins
Hi,
I didn't completely understand your answer... - which template would that be?
So I want to add extra fields to a certain category and its children, and would need to do that without breaking future aimeos updates (I've already created an extension).

thanks!

Re: Product multiple relationship with a different Model

Posted: 16 Jul 2018, 17:22
by aimeos
In the catalog/lists/body-standard.php you have the categories up to the root node:
https://github.com/aimeos/ai-client-htm ... rd.php#L11

You can get data from the key/value array of each node:
https://github.com/aimeos/ai-client-htm ... rd.php#L25

Or you can get texts, media, etc. from each node:
https://github.com/aimeos/ai-client-htm ... rd.php#L55

Re: Product multiple relationship with a different Model

Posted: 16 Jul 2018, 18:00
by Nelson Martins
Ok, those are examples on how to get info from the categories, and that's all right.

I think the question remains in terms of backoffice - how can we have, besides, for instance, the fields in the Basic tab:
- Status
- Code
- Label
- URL target

...those other custom fields I've mentioned before:

- Brand (should be a taxonomy of terms)
- Series (text field)
- Model (text field)

I've noticed 'Options' can be created on the fly, but that's not the idea, these would have to be fixed fields (and displaying only on the admin pages of some specific categories).

Re: Product multiple relationship with a different Model

Posted: 17 Jul 2018, 21:51
by aimeos
If you need something special, you can adapt the catalog panel implementation to match your requirements in your own Aimeos extension.