| @@ 14-129 (lines=116) @@ | ||
| 11 | ||
| 12 | namespace Ecommerce\Item\Offer; |
|
| 13 | ||
| 14 | class Param extends \Model { |
|
| 15 | ||
| 16 | public static $objectName = 'Параметр товара'; |
|
| 17 | public static $labels = [ |
|
| 18 | 'item_offer_option_id' => 'Параметр предложения', |
|
| 19 | 'item_offer_id' => 'Предложение', |
|
| 20 | 'value' => 'Значение', |
|
| 21 | ]; |
|
| 22 | public static $cols = [ |
|
| 23 | //Основные параметры |
|
| 24 | 'item_offer_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'offer'], |
|
| 25 | 'item_offer_option_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'option', 'onChange' => 'reloadForm'], |
|
| 26 | 'value' => ['type' => 'dynamicType', 'typeSource' => 'selfMethod', 'selfMethod' => 'realType'], |
|
| 27 | //Системные |
|
| 28 | 'date_create' => ['type' => 'dateTime'] |
|
| 29 | ]; |
|
| 30 | ||
| 31 | public static function indexes() { |
|
| 32 | return [ |
|
| 33 | 'ecommerce_itemOfferOptionRelation' => [ |
|
| 34 | 'type' => 'INDEX', |
|
| 35 | 'cols' => [ |
|
| 36 | 'item_offer_param_item_offer_id', |
|
| 37 | 'item_offer_param_item_offer_option_id' |
|
| 38 | ] |
|
| 39 | ], |
|
| 40 | 'ecommerce_paramItemOfferIndex' => [ |
|
| 41 | 'type' => 'INDEX', |
|
| 42 | 'cols' => [ |
|
| 43 | 'item_offer_param_item_offer_id', |
|
| 44 | ] |
|
| 45 | ], |
|
| 46 | 'ecommerce_paramOfferOptionIndex' => [ |
|
| 47 | 'type' => 'INDEX', |
|
| 48 | 'cols' => [ |
|
| 49 | 'item_offer_param_item_offer_option_id' |
|
| 50 | ] |
|
| 51 | ], |
|
| 52 | ]; |
|
| 53 | } |
|
| 54 | ||
| 55 | public function realType() { |
|
| 56 | if ($this->option && $this->option->type) { |
|
| 57 | $type = $this->option->type; |
|
| 58 | ||
| 59 | if ($type == 'select') { |
|
| 60 | return [ |
|
| 61 | 'type' => 'select', |
|
| 62 | 'source' => 'relation', |
|
| 63 | 'relation' => 'option:items', |
|
| 64 | ]; |
|
| 65 | } |
|
| 66 | return $type; |
|
| 67 | } |
|
| 68 | return 'text'; |
|
| 69 | } |
|
| 70 | ||
| 71 | public static $dataManagers = [ |
|
| 72 | ||
| 73 | 'manager' => [ |
|
| 74 | 'name' => 'Параметры предложения', |
|
| 75 | 'cols' => [ |
|
| 76 | 'item_offer_option_id', |
|
| 77 | 'item_offer_id', |
|
| 78 | 'value', |
|
| 79 | ], |
|
| 80 | ], |
|
| 81 | ]; |
|
| 82 | public static $forms = [ |
|
| 83 | 'manager' => [ |
|
| 84 | 'map' => [ |
|
| 85 | ['item_offer_id', 'item_offer_option_id'], |
|
| 86 | ['value'] |
|
| 87 | ] |
|
| 88 | ]]; |
|
| 89 | ||
| 90 | function name() { |
|
| 91 | return $this->value; |
|
| 92 | } |
|
| 93 | ||
| 94 | public function value($default = '') { |
|
| 95 | if ($this->option->type != 'select') { |
|
| 96 | return $this->value; |
|
| 97 | } elseif ($this->optionItem) { |
|
| 98 | return $this->optionItem->value; |
|
| 99 | } |
|
| 100 | return $default; |
|
| 101 | } |
|
| 102 | ||
| 103 | public static function relations() { |
|
| 104 | return [ |
|
| 105 | 'file' => [ |
|
| 106 | 'model' => 'Files\File', |
|
| 107 | 'col' => 'value' |
|
| 108 | ], |
|
| 109 | 'option' => [ |
|
| 110 | 'model' => 'Ecommerce\Item\Offer\Option', |
|
| 111 | 'col' => 'item_offer_option_id' |
|
| 112 | ], |
|
| 113 | 'offer' => [ |
|
| 114 | 'model' => 'Ecommerce\Item\Offer', |
|
| 115 | 'col' => 'item_offer_id' |
|
| 116 | ], |
|
| 117 | 'optionItem' => [ |
|
| 118 | 'model' => 'Ecommerce\Item\Offer\Option\Item', |
|
| 119 | 'col' => 'value' |
|
| 120 | ] |
|
| 121 | ]; |
|
| 122 | } |
|
| 123 | ||
| 124 | } |
|
| 125 | ||
| @@ 14-129 (lines=116) @@ | ||
| 11 | ||
| 12 | namespace Ecommerce\Item; |
|
| 13 | ||
| 14 | class Param extends \Model { |
|
| 15 | ||
| 16 | public static $objectName = 'Параметр товара'; |
|
| 17 | public static $labels = [ |
|
| 18 | 'item_option_id' => 'Параметр', |
|
| 19 | 'item_id' => 'Товар', |
|
| 20 | 'value' => 'Значение', |
|
| 21 | ]; |
|
| 22 | public static $cols = [ |
|
| 23 | //Основные параметры |
|
| 24 | 'item_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'item'], |
|
| 25 | 'item_option_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'option', 'onChange' => 'reloadForm'], |
|
| 26 | 'value' => ['type' => 'dynamicType', 'typeSource' => 'selfMethod', 'selfMethod' => 'realType'], |
|
| 27 | //Системные |
|
| 28 | 'date_create' => ['type' => 'dateTime'] |
|
| 29 | ]; |
|
| 30 | ||
| 31 | public static function indexes() { |
|
| 32 | return [ |
|
| 33 | 'ecommerce_itemOptionRelation' => [ |
|
| 34 | 'type' => 'INDEX', |
|
| 35 | 'cols' => [ |
|
| 36 | 'item_param_item_id', |
|
| 37 | 'item_param_item_option_id' |
|
| 38 | ] |
|
| 39 | ], |
|
| 40 | 'ecommerce_paramItemIndex' => [ |
|
| 41 | 'type' => 'INDEX', |
|
| 42 | 'cols' => [ |
|
| 43 | 'item_param_item_id', |
|
| 44 | ] |
|
| 45 | ], |
|
| 46 | 'ecommerce_paramOptionIndex' => [ |
|
| 47 | 'type' => 'INDEX', |
|
| 48 | 'cols' => [ |
|
| 49 | 'item_param_item_option_id' |
|
| 50 | ] |
|
| 51 | ], |
|
| 52 | ]; |
|
| 53 | } |
|
| 54 | ||
| 55 | public function realType() { |
|
| 56 | if ($this->option) { |
|
| 57 | $type = $this->option->type; |
|
| 58 | ||
| 59 | if ($type == 'select') { |
|
| 60 | return [ |
|
| 61 | 'type' => 'select', |
|
| 62 | 'source' => 'relation', |
|
| 63 | 'relation' => 'option:items', |
|
| 64 | ]; |
|
| 65 | } |
|
| 66 | return $type; |
|
| 67 | } |
|
| 68 | return 'text'; |
|
| 69 | } |
|
| 70 | ||
| 71 | public static $dataManagers = [ |
|
| 72 | ||
| 73 | 'manager' => [ |
|
| 74 | 'name' => 'Параметры товара', |
|
| 75 | 'cols' => [ |
|
| 76 | 'item_option_id', |
|
| 77 | 'item_id', |
|
| 78 | 'value', |
|
| 79 | ], |
|
| 80 | ], |
|
| 81 | ]; |
|
| 82 | public static $forms = [ |
|
| 83 | 'manager' => [ |
|
| 84 | 'map' => [ |
|
| 85 | ['item_id', 'item_option_id'], |
|
| 86 | ['value'] |
|
| 87 | ] |
|
| 88 | ]]; |
|
| 89 | ||
| 90 | function name() { |
|
| 91 | return $this->value; |
|
| 92 | } |
|
| 93 | ||
| 94 | public function value($default = '') { |
|
| 95 | if ($this->option->type != 'select') { |
|
| 96 | return $this->value; |
|
| 97 | } elseif ($this->optionItem) { |
|
| 98 | return $this->optionItem->value; |
|
| 99 | } |
|
| 100 | return $default; |
|
| 101 | } |
|
| 102 | ||
| 103 | public static function relations() { |
|
| 104 | return [ |
|
| 105 | 'file' => [ |
|
| 106 | 'model' => 'Files\File', |
|
| 107 | 'col' => 'value' |
|
| 108 | ], |
|
| 109 | 'option' => [ |
|
| 110 | 'model' => 'Ecommerce\Item\Option', |
|
| 111 | 'col' => 'item_option_id' |
|
| 112 | ], |
|
| 113 | 'item' => [ |
|
| 114 | 'model' => 'Ecommerce\Item', |
|
| 115 | 'col' => 'item_id' |
|
| 116 | ], |
|
| 117 | 'optionItem' => [ |
|
| 118 | 'model' => 'Ecommerce\Item\Option\Item', |
|
| 119 | 'col' => 'value' |
|
| 120 | ] |
|
| 121 | ]; |
|
| 122 | } |
|
| 123 | ||
| 124 | } |
|
| 125 | ||