Silverstripe Version:
4.7
Question:
I’ve a many many relation from “Invoice” to “Product”.
On “Invoice” i’ve defined the many many extra fields “PurchasedPrice”, “Quantity” and “PriceTotal”.
Now how can i show these entries on the product summary fields when i’m on a invoice object in the products tab?
Details of your query go here
class Invoice extends DataObject
{
private static $db = [
"Title" => "Varchar",
"LastReminder" => "Date",
"Deadline" => "Date",
"Total" => "Currency",
"IsPaid" => "Boolean",
];
private static $has_one = [
"Member" => Member::class,
];
private static $many_many = [
"Products" => Product::class,
];
private static $many_many_extraFields = [
"Products" => [
"PurchasedPrice" => "Currency",
"Quantity" => "Int",
"PriceTotal" => "Currency",
],
];
private static $summary_fields = [
"Created.Nice" => "Created",
"Member.Name" => "For Member",
"Title" => "Title",
"Total" => "Total Price",
"IsPaid" => "Is paid?",
];
....
}
class Product extends DataObject
{
private static $db = [
"Name" => "Varchar",
"Price" => "Currency",
"IsActive" => "Boolean",
];
private static $has_one = [
"Category" => Category::class,
"Image" => Image::class,
];
private static $belongs_many_many = [
"Invoices" => Invoice::class,
];
private static $summary_fields = array(
"IsActive" => "Is active?",
"Name" => "Name",
"Category.Title" => "Category",
"Price" => "Price",
);
.....
}