Let's say I have two Entry
channels: Items and Collections. Collections have a relatedItems
field in them. Items aren't unique to a Collection, and based on the Collection they're in, they could have a different quantity than the same item in a different collection.
I know I could create a matrix field called relatedItems
, where each block has a field to choose the Item Entry
and a number field to enter the quantity. My issue with this is there'll be thousands of Items and Collections, so there'll be multiple single-use Entry
matrix blocks for the same Item spread out over many Collections. It feels incorrect, like I'll be generating unnecessary bloat in my database.
Another idea I thought of is to use a Table field in Collection entries. One column would be the related Item's Entry
ID, and the other column would be the Item's quantity for that Collection. Now, there's only one Entry
per Item (in the "Items" channel), whose ID can be referenced in multiple places along with a quantity. My only issue with this is that, when I view a Collection entry, I'll just see a bunch of IDs listed in a table. I can't easily jump to the Item entry to edit something like I could if it was a matrix block with a relation field.
Is there something I'm overlooking in Craft 5 to solve this? Since a channel has Entry
elements and matrix fields (as of Craft 5) uses Entry
elements too for their blocks, I don't want to create multiple entries/blocks for one Item. It seems redundant and excessive. Any advanced techniques I'm not thinking of?
PS, this isn't an e-commerce site. I'm trying to simplify the names of the channels for the sake of this post.