Hi experts,
I'm extending a product page via DataExtension
class ProductPropertiesExtension extends DataExtension {
…..
private static $has_many = array(
'Accessories' => 'ProductAccessory'
);
…...
with Accessory.php
class ProductAccessory extends DataObject {
private static $db = array(
'ProductID' => 'Int'
);
private static $has_one = array(
'Product' => 'Product'
);
}
The table ProductAccessory is created.
Then I try to add a grid field in my extension class with:
(the GridField is not yet configured correctly, it's just a test)
public function updateCMSFields(FieldList $fields) {
// Create a default configuration for the new GridField, allowing record editing
$config = GridFieldConfig_RelationEditor::create();
// Set the names and data for our gridfield columns
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
'Title' => 'Title'
));
// Create a gridfield to hold the accessory relationship
$accessoriesField = new GridField(
'Accessories', // Field name
'Product', // Field title
$this->Accessories(), // List of all related accessories
$config
);
// Create a tab named "Accessories" and add our field to it
$fields->addFieldToTab('Root.Accessories', $accessoriesField);
}
But then I get the error:
Call to undefined method ProductPropertiesExtension::Accessories() in /Applications/XAMPP/xamppfiles/htdocs/swipestripe-funds/code/Product.php on line 352
What am I doing wrong?
TIA Stephan