EspoCRM Ebla Link Pro Relationships Data Modeling

Model Order Items with Ebla Link Pro in EspoCRM

Eymen Elkum headshot Eymen Elkum
EspoCRM Order and Product records connected through an Order Product Item middle entity

Use a middle entity in EspoCRM when an Order-to-Product relationship needs price or other row-level data.

An Order and Product may look like a many-to-many relationship, but quantity, unit price, discount, and line notes belong to the relationship occurrence. Those values need their own record.

The example verified in this guide uses:

Order → Order Product Item → Product

Ebla Link Pro calls this the Middle Link pattern.

Requirements

This guide targets Ebla Link Pro 3.58 or later, EspoCRM 9.3 or later, and PHP 8.1 or later. Complete the setup in a test environment before migrating existing order data.

Why not use a direct many-to-many field?

Link Pro can display direct many-to-many fields and provide actions such as view, edit, unlink, and remove. It does not provide inline field editing for a direct many-to-many relationship.

Use a middle entity when each selected Product needs its own values.

Step 1: Create the Order Product Item entity

Open Administration → Entity Manager → Create Entity and create OrderProductItem using the Base type.

Create the fields required by each row, for example:

LabelInternal nameType
ProductproductLink
PricepriceFloat or Currency

Add quantity, discount, tax, line-total, or note fields when the business process requires them. Apply validation and Formula rules appropriate to those fields.

Step 2: Create the relationships

From Entity Manager, create:

  1. A one-to-many relationship from Order to Order Product Item.
  2. A many-to-one relationship from Order Product Item to Product.

After saving, record the internal names of:

  • the Link Multiple field on Order, such as orderProductItems;
  • the Link field on Order Product Item that points to Product, such as product.

Do not create a separate direct Order-to-Product many-to-many relationship for the same editable rows.

Open Administration → Entity Manager → Order → Fields → Order Product Items and:

  1. Enable Enable Form.
  2. Choose the detail and edit layouts.
  3. Enable Enable Select Button to let users choose existing Products.
  4. Set Middle Link (Act As Middle Entity) to Product.
  5. Enable Is Middle Link Unique when the same Product must not appear twice.
  6. Enable Open Middle Entity when row actions should open the Order Product Item instead of the final Product.
  7. Configure Copy Fields if Product values should be copied into the Order Product Item.
  8. Save the field.

EspoCRM Ebla Link Pro settings with Enable Form selected and Product configured as the Middle Link

Middle Link (Act As Middle Entity) identifies Product as the final record represented by each Order Product Item row.

Step 4: Configure the inline layout

Include fields that users need to understand or edit:

  • Product;
  • Price;
  • any optional quantity, discount, tax, or line-total fields created for the process.

Keep calculated and protected fields read-only. Use the Link Pro Custom Layout setting when the Order Product Items list requires a dedicated column arrangement.

Step 5: Add the field to Order layouts

Add Order Product Items to the Order Detail and Edit layouts. Save the layouts and run Administration → Rebuild if the new metadata is not visible immediately.

Optional: copy Product values

Use Copy Fields when selecting a Product should initialize fields such as price or a tax code on the Order Product Item.

Copied values are snapshots. Decide whether later Product changes should affect historical Order Product Items before enabling any automatic resynchronization.

Test the relationship

  1. Create an Order and select a Product.
  2. Confirm that one Order Product Item is created in the inline list.
  3. Enter the row price, then save the Order.
  4. Reopen both the Order and Order Product Item and verify their links.
  5. Try to select the same Product twice when uniqueness is enabled.
  6. Test create, edit, view, unlink, and remove actions with restricted user roles.
  7. Confirm whether row actions open the intended middle or final record.

Common problems

Product is selected but row fields cannot be edited

Confirm that Order uses the one-to-many orderProductItems field with Product selected as its Middle Link. A direct many-to-many Products field does not support inline row editing.

The same Product appears more than once

Enable Is Middle Link Unique and verify that Product is the configured Middle Link.

Users can edit protected values

Add those fields to Link Pro Read-only Fields and enforce any security-critical rule on the server as well.