Hi friends,
Today I will explain how you can use our extension “Link Multiple Pro” with many-to-Many (n:n) relationships.
In this article we assume the following entities Order & Product, and we need to add link n:n between them.
Step 1:
Create the middle entity manually.
Dont create n:n relationship directly using the entity manager
You can name this middle entity any name but we prefer one of these patterns:
– OrderProduct (I will choose this name)
– OrderItem
– OrderProductItem
– OrderProductMiddle
To make this more real we will add 2 fields to the middle entity:
– Price
– Quantity
Step 2:
Go to #Admin/linkManager/scope=OrderProduct (OrderProduct/relationships) add these two links:
– Order has many OrderProduct
– Product has many OrderProduct
Step 3:
Go to: Admin > Entity Manager > Order > fields > orderProducts:
#Admin/fieldManager/scope=Order&field=orderProducts
In the fields options do these:
- Enable form
- Select List Small layout or just fill the next input with the fields you want to display on the list. NOTE: if you have “Layout Pro” I prefer to create a new list layout and select it here.
- Here is the most important step set the “Middle Link” to “Product”.
- Other settings are optional
- Save and add the orderProducts field to the Order detail layout.
- add price & entity to the OrderProduct selected list layout (Optional).
- You are done!