class Product extends CubistMagicModel
{
+ protected static $_specifications = null;
+ protected static $_productTypes = null;
+
protected $table = 'catalog_products';
protected $_options = ['name' => 'product',
'type' => 'Markdown',
'tab' => 'Textes']);
+// $this->addField(['name' => 'related',
+// 'label' => 'Produits associƩs',
+// 'type' => 'SelectFromModel',
+// 'optionsmodel' => 'App\Models\Product',
+// 'multiple' => true,
+// 'tab'=>'Produits associƩs'
+// ]);
+
+
$this->addSpecifications();
}
+ protected static function _getRelatedEntities()
+ {
+ if (null === self::$_specifications) {
+ self::$_specifications = Specification::all();
+ self::$_productTypes = ProductType::all();
+ }
+ }
public function addSpecifications()
{
- $specifications = Specification::all();
- $types = ProductType::all();
+ self::_getRelatedEntities();
- foreach ($specifications as $spec) {
+ foreach (self::$_specifications as $spec) {
$in = [];
- foreach ($types as $type) {
+ foreach (self::$_productTypes as $type) {
$lists = [$type->specifications, $type->filters];
foreach ($lists as $list) {
if (!is_array($list)) {