By default, AtroPIM uses many-to-many relationships e.g. between products and categories. This uses the relation table product_category with columns category_id and product_id.
I’ve tried to create a new many-to-many relationship between products and products, but it didn’t work. The created relation table product_product only contains one product_id and is missing the second ID for the foreign key. I’ve looked into the source code of AtroPIM and it appers that the class \Espo\Core\Utils\Database\Orm\Relations\ManyMany cannot handle a relationship where the entity and the foreign entity are of the same type.
My use case is to add products as accessories to a main product and to view which products are linked to a given product. For example:
- Product “Notebook” has products “Keyboard” and “Mouse” as accessories
- Product “Tablet” has product “Keyboard” as accessory
- → Product “Keyboard” has products “Notebook” and “Tablet” as linked products (reverse)
Do you know if this could be achieved with the paid module “Advanced Data Types” or if there is another workaround that I have overlooked?