/** * Add custom attributes to tl_iso_product DCA */ protected function addAttributes() { $arrData =& $GLOBALS['TL_DCA'][Product::getTable()]; $arrData['attributes'] = array(); // Write attributes from database to DCA /** @var \Isotope\Model\Attribute[] $objAttributes */ if (($objAttributes = Attribute::findValid()) !== null) { foreach ($objAttributes as $objAttribute) { if (null !== $objAttribute) { $objAttribute->saveToDCA($arrData); $arrData['attributes'][$objAttribute->field_name] = $objAttribute; } } } // Create temporary models for non-database attributes foreach (array_diff_key($arrData['fields'], $arrData['attributes']) as $strName => $arrConfig) { if (is_array($arrConfig['attributes'])) { if ($arrConfig['attributes']['type'] != '') { $strClass = $arrConfig['attributes']['type']; } else { $strClass = Attribute::getClassForModelType($arrConfig['inputType']); } if ($strClass != '') { /** @type Attribute $objAttribute */ $objAttribute = new $strClass(); $objAttribute->loadFromDCA($arrData, $strName); $arrData['attributes'][$strName] = $objAttribute; } } } }