I have some code similar to the following:
class Order extends DataObject
{
private static $many_many = [
'Items' => [
'through' => OrderItem::class,
'from' => 'Order',
'to' => 'Item',
]
];
}
class Item extends DataObject
{
private static $belongs_many_many = [
'Orders' => Order::class,
];
}
class OrderItem extends DataObject
{
private static $db = [
'Price' => 'Decimal(5,2)',
'Quantity' => 'Int',
];
private static $has_one = [
'Order' => Order::class,
'Item' => Item::class,
];
}
I need to allow the same item to be included in the same order multiple times.
Is this even possible? I’m asking because I’m hitting many issues in the GridField support, e.g. GridFieldAddExistingAutocompleter
removes an item from the searchable list once you added it to the order and GridFieldDeleteAction
deletes all the OrderItem
instances with the same item ID.