Product multiple relationship with a different Model

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Nelson Martins
Posts: 7
Joined: 05 Jul 2018, 16:13

Product multiple relationship with a different Model

Post by Nelson Martins » 05 Jul 2018, 17:33

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!

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Product multiple relationship with a different Model

Post by aimeos » 06 Jul 2018, 11:28

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.)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Nelson Martins
Posts: 7
Joined: 05 Jul 2018, 16:13

Re: Product multiple relationship with a different Model

Post by Nelson Martins » 06 Jul 2018, 12:35

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?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Product multiple relationship with a different Model

Post by aimeos » 06 Jul 2018, 14:02

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Nelson Martins
Posts: 7
Joined: 05 Jul 2018, 16:13

Re: Product multiple relationship with a different Model

Post by Nelson Martins » 10 Jul 2018, 08:26

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?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Product multiple relationship with a different Model

Post by aimeos » 10 Jul 2018, 20:23

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Nelson Martins
Posts: 7
Joined: 05 Jul 2018, 16:13

Re: Product multiple relationship with a different Model

Post by Nelson Martins » 16 Jul 2018, 16:03

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!

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Product multiple relationship with a different Model

Post by aimeos » 16 Jul 2018, 17:22

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Nelson Martins
Posts: 7
Joined: 05 Jul 2018, 16:13

Re: Product multiple relationship with a different Model

Post by Nelson Martins » 16 Jul 2018, 18:00

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).

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Product multiple relationship with a different Model

Post by aimeos » 17 Jul 2018, 21:51

If you need something special, you can adapt the catalog panel implementation to match your requirements in your own Aimeos extension.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply