This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

herzgarlan22551
herzgarlan22551

Hi,

I'm building a plugin for handling Products and Products' movement, Inserting to the ProductMovement table will be done via different triggers (e.g. product create, product update, job orders).

I want to display this list inside the Product when it's being updated. I've added a relation in my Products model also have the partial to be displayed as well but no data are shown, can someone enlighten me? I know this has something to do with Pivot table but I tried that path as well but to no avail.

Product Model:

public $hasMany = [
    'productmovement' => ['HerzGarlan\Inventory\Models\ProductMovement',
        'otherKey'=>'product_id',
        'otherKey'=>'backend_user_id',
    ],
];

Product Model/fields.yaml:

productmovement: label: Product Movements type: partial path: field_productmovement

Product/Controller/config_relation.yaml:

productmovement: label: Product Movement manage: form: $/wms/inventory/models/productmovement/fields.yaml list: $/wms/inventory/models/productmovement/columns.yaml view: list: $/wms/inventory/models/productmovement/columns.yaml toolbarButtons: create|delete readOnly: true showSearch: true

Last updated

Crazymodder
Crazymodder

Hi,

First: "ProductMovement table will be done via different triggers (e.g. product create, product update, job orders)"

this sounds not right to mee. But maybe I missunderstand your requirement.

Second:

'otherKey'=>'product_id',
'otherKey'=>'backend_user_id',

What are you trying to do here? Can you give little more input? what does otherKey mean in this context?

Regards Crazymodder

herzgarlan22551
herzgarlan22551

Hi Crazymodder,

Found out that I don't need those otherKey and it's working now just got confused with backend relation stuffs.

Thanks though

Last updated

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.