@@ -13,57 +13,57 @@ discard block |
||
13 | 13 | |
14 | 14 | class Item extends \Model { |
15 | 15 | |
16 | - public static $categoryModel = 'Ecommerce\Category'; |
|
17 | - public static $objectName = 'Товар'; |
|
18 | - public static $labels = [ |
|
19 | - 'name' => 'Название', |
|
20 | - 'alias' => 'Алиас', |
|
21 | - 'category_id' => 'Раздел', |
|
22 | - 'description' => 'Описание', |
|
23 | - 'item_type_id' => 'Тип товара', |
|
24 | - 'image_file_id' => 'Изображение', |
|
25 | - 'best' => 'Лучшее предложение', |
|
26 | - 'options' => 'Параметры', |
|
27 | - 'offers' => 'Торговые предложения', |
|
28 | - 'widget' => 'Виджет для отображения в каталоге', |
|
29 | - 'view' => 'Шаблон для отображения полной информации', |
|
30 | - 'deleted' => 'Удален', |
|
31 | - 'imgs' => 'Фото' |
|
32 | - ]; |
|
33 | - public static $cols = [ |
|
34 | - //Основные параметры |
|
35 | - 'category_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'category'], |
|
36 | - 'image_file_id' => ['type' => 'image'], |
|
37 | - 'name' => ['type' => 'text'], |
|
38 | - 'alias' => ['type' => 'text'], |
|
39 | - 'description' => ['type' => 'html'], |
|
40 | - 'item_type_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'type'], |
|
41 | - 'best' => ['type' => 'bool'], |
|
42 | - 'deleted' => ['type' => 'bool'], |
|
43 | - //Системные |
|
44 | - 'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'], |
|
45 | - 'weight' => ['type' => 'number'], |
|
46 | - 'sales' => ['type' => 'number'], |
|
47 | - 'imported' => ['type' => 'text'], |
|
48 | - 'tree_path' => ['type' => 'text'], |
|
49 | - 'search_index' => ['type' => 'text'], |
|
50 | - 'date_create' => ['type' => 'dateTime'], |
|
51 | - 'widget' => ['type' => 'text'], |
|
52 | - 'view' => ['type' => 'text'], |
|
53 | - //Менеджеры |
|
54 | - 'options' => ['type' => 'dataManager', 'relation' => 'options'], |
|
55 | - 'offers' => ['type' => 'dataManager', 'relation' => 'offers'], |
|
56 | - 'imgs' => ['type' => 'dataManager', 'relation' => 'images'], |
|
57 | - ]; |
|
16 | + public static $categoryModel = 'Ecommerce\Category'; |
|
17 | + public static $objectName = 'Товар'; |
|
18 | + public static $labels = [ |
|
19 | + 'name' => 'Название', |
|
20 | + 'alias' => 'Алиас', |
|
21 | + 'category_id' => 'Раздел', |
|
22 | + 'description' => 'Описание', |
|
23 | + 'item_type_id' => 'Тип товара', |
|
24 | + 'image_file_id' => 'Изображение', |
|
25 | + 'best' => 'Лучшее предложение', |
|
26 | + 'options' => 'Параметры', |
|
27 | + 'offers' => 'Торговые предложения', |
|
28 | + 'widget' => 'Виджет для отображения в каталоге', |
|
29 | + 'view' => 'Шаблон для отображения полной информации', |
|
30 | + 'deleted' => 'Удален', |
|
31 | + 'imgs' => 'Фото' |
|
32 | + ]; |
|
33 | + public static $cols = [ |
|
34 | + //Основные параметры |
|
35 | + 'category_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'category'], |
|
36 | + 'image_file_id' => ['type' => 'image'], |
|
37 | + 'name' => ['type' => 'text'], |
|
38 | + 'alias' => ['type' => 'text'], |
|
39 | + 'description' => ['type' => 'html'], |
|
40 | + 'item_type_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'type'], |
|
41 | + 'best' => ['type' => 'bool'], |
|
42 | + 'deleted' => ['type' => 'bool'], |
|
43 | + //Системные |
|
44 | + 'user_id' => ['type' => 'select', 'source' => 'relation', 'relation' => 'user'], |
|
45 | + 'weight' => ['type' => 'number'], |
|
46 | + 'sales' => ['type' => 'number'], |
|
47 | + 'imported' => ['type' => 'text'], |
|
48 | + 'tree_path' => ['type' => 'text'], |
|
49 | + 'search_index' => ['type' => 'text'], |
|
50 | + 'date_create' => ['type' => 'dateTime'], |
|
51 | + 'widget' => ['type' => 'text'], |
|
52 | + 'view' => ['type' => 'text'], |
|
53 | + //Менеджеры |
|
54 | + 'options' => ['type' => 'dataManager', 'relation' => 'options'], |
|
55 | + 'offers' => ['type' => 'dataManager', 'relation' => 'offers'], |
|
56 | + 'imgs' => ['type' => 'dataManager', 'relation' => 'images'], |
|
57 | + ]; |
|
58 | 58 | |
59 | - public static function simpleItemHandler($request) { |
|
59 | + public static function simpleItemHandler($request) { |
|
60 | 60 | if ($request) { |
61 | - $item = new Item(); |
|
62 | - $item->name = $request['name']; |
|
63 | - $item->description = $request['description']; |
|
64 | - $item->category_id = $request['category']; |
|
65 | - $item->save(); |
|
66 | - if (!empty($_FILES['ActiveForm_simpleItem']['tmp_name']['Ecommerce\Item']['image'])) { |
|
61 | + $item = new Item(); |
|
62 | + $item->name = $request['name']; |
|
63 | + $item->description = $request['description']; |
|
64 | + $item->category_id = $request['category']; |
|
65 | + $item->save(); |
|
66 | + if (!empty($_FILES['ActiveForm_simpleItem']['tmp_name']['Ecommerce\Item']['image'])) { |
|
67 | 67 | $file_id = \App::$primary->files->upload([ |
68 | 68 | 'tmp_name' => $_FILES['ActiveForm_simpleItem']['tmp_name']['Ecommerce\Item']['image'], |
69 | 69 | 'name' => $_FILES['ActiveForm_simpleItem']['name']['Ecommerce\Item']['image'], |
@@ -75,131 +75,131 @@ discard block |
||
75 | 75 | 'accept_group' => 'image' |
76 | 76 | ]); |
77 | 77 | if ($file_id) { |
78 | - $item->image_file_id = $file_id; |
|
79 | - $item->save(); |
|
78 | + $item->image_file_id = $file_id; |
|
79 | + $item->save(); |
|
80 | + } |
|
80 | 81 | } |
81 | - } |
|
82 | - if (!empty($request['options']['option'])) { |
|
82 | + if (!empty($request['options']['option'])) { |
|
83 | 83 | foreach ($request['options']['option'] as $key => $option_id) { |
84 | - $param = new Item\Param(); |
|
85 | - $param->item_id = $item->id; |
|
86 | - $param->value = $request['options']['value'][$key]; |
|
87 | - $param->item_option_id = $option_id; |
|
88 | - $param->save(); |
|
84 | + $param = new Item\Param(); |
|
85 | + $param->item_id = $item->id; |
|
86 | + $param->value = $request['options']['value'][$key]; |
|
87 | + $param->item_option_id = $option_id; |
|
88 | + $param->save(); |
|
89 | 89 | } |
90 | - } |
|
91 | - $offer = new Item\Offer(); |
|
92 | - $offer->item_id = $item->id; |
|
93 | - $offer->save(); |
|
94 | - if (!empty($request['offerOptions']['option'])) { |
|
90 | + } |
|
91 | + $offer = new Item\Offer(); |
|
92 | + $offer->item_id = $item->id; |
|
93 | + $offer->save(); |
|
94 | + if (!empty($request['offerOptions']['option'])) { |
|
95 | 95 | foreach ($request['offerOptions']['option'] as $key => $option_id) { |
96 | - $param = new Item\Offer\Param(); |
|
97 | - $param->item_offer_id = $offer->id; |
|
98 | - $param->value = $request['offerOptions']['value'][$key]; |
|
99 | - $param->item_offer_option_id = $option_id; |
|
100 | - $param->save(); |
|
96 | + $param = new Item\Offer\Param(); |
|
97 | + $param->item_offer_id = $offer->id; |
|
98 | + $param->value = $request['offerOptions']['value'][$key]; |
|
99 | + $param->item_offer_option_id = $option_id; |
|
100 | + $param->save(); |
|
101 | + } |
|
101 | 102 | } |
102 | - } |
|
103 | - $price = new Item\Offer\Price(); |
|
104 | - $price->price = $request['price']; |
|
105 | - $price->item_offer_id = $offer->id; |
|
106 | - $price->currency_id = $request['currency']; |
|
107 | - $price->save(); |
|
103 | + $price = new Item\Offer\Price(); |
|
104 | + $price->price = $request['price']; |
|
105 | + $price->item_offer_id = $offer->id; |
|
106 | + $price->currency_id = $request['currency']; |
|
107 | + $price->save(); |
|
108 | + } |
|
108 | 109 | } |
109 | - } |
|
110 | 110 | |
111 | - public static $dataManagers = [ |
|
112 | - 'manager' => [ |
|
113 | - 'name' => 'Товары', |
|
114 | - 'cols' => [ |
|
115 | - 'name', |
|
116 | - 'imgs', |
|
117 | - 'category_id', |
|
118 | - 'item_type_id', |
|
119 | - 'best', |
|
120 | - 'deleted', |
|
121 | - 'options', |
|
122 | - 'offers', |
|
123 | - ], |
|
124 | - 'categorys' => [ |
|
125 | - 'model' => 'Ecommerce\Category', |
|
126 | - ], |
|
127 | - 'sortMode' => true |
|
128 | - ] |
|
129 | - ]; |
|
130 | - public static $forms = [ |
|
131 | - 'manager' => [ |
|
132 | - 'map' => [ |
|
133 | - ['name', 'alias'], |
|
134 | - ['category_id', 'item_type_id', 'deleted'], |
|
135 | - ['widget', 'view'], |
|
136 | - ['best', 'image_file_id'], |
|
137 | - ['description'], |
|
138 | - ['imgs'], |
|
139 | - ['options'], |
|
140 | - ['offers'], |
|
141 | - ] |
|
142 | - ], |
|
143 | - 'simpleItem' => [ |
|
144 | - 'options' => [ |
|
145 | - 'access' => [ |
|
146 | - 'groups' => [ |
|
147 | - 3 |
|
148 | - ] |
|
149 | - ], |
|
150 | - ], |
|
151 | - 'name' => 'Простой товар с ценой', |
|
152 | - 'inputs' => [ |
|
153 | - 'name' => ['type' => 'text'], |
|
154 | - 'description' => ['type' => 'html'], |
|
155 | - 'category' => ['type' => 'select', 'source' => 'model', 'model' => 'Ecommerce\Category', 'label' => 'Категория'], |
|
156 | - 'image' => ['type' => 'image', 'label' => 'Изображение'], |
|
157 | - 'price' => ['type' => 'text', 'label' => 'Цена'], |
|
158 | - 'currency' => ['type' => 'select', 'source' => 'model', 'model' => 'Money\Currency', 'label' => 'Валюта'], |
|
159 | - 'options' => ['type' => 'dynamicList', 'source' => 'options', 'options' => [ |
|
160 | - 'inputs' => [ |
|
161 | - 'option' => ['type' => 'select', 'source' => 'model', 'model' => 'Ecommerce\Item\Option', 'label' => 'Свойство'], |
|
162 | - 'value' => ['type' => 'dynamicType', 'typeSource' => 'selfMethod', 'selfMethod' => 'realType', 'label' => 'Значение'], |
|
163 | - ] |
|
164 | - ] |
|
165 | - ], |
|
166 | - 'offerOptions' => ['type' => 'dynamicList', 'source' => 'options', 'options' => [ |
|
167 | - 'inputs' => [ |
|
168 | - 'option' => ['type' => 'select', 'source' => 'model', 'model' => 'Ecommerce\Item\Offer\Option', 'label' => 'Свойство предложения'], |
|
169 | - 'value' => ['type' => 'dynamicType', 'typeSource' => 'selfMethod', 'selfMethod' => 'realType', 'label' => 'Значение'], |
|
170 | - ] |
|
171 | - ],'label'=>'Параметры предложения' |
|
172 | - ] |
|
173 | - ], |
|
174 | - 'map' => [ |
|
175 | - ['name', 'category'], |
|
176 | - ['description'], |
|
177 | - ['image'], |
|
178 | - ['price', 'currency'], |
|
179 | - ['options'], |
|
180 | - ['offerOptions'], |
|
181 | - ], |
|
182 | - 'handler' => 'simpleItemHandler' |
|
183 | - ] |
|
184 | - ]; |
|
111 | + public static $dataManagers = [ |
|
112 | + 'manager' => [ |
|
113 | + 'name' => 'Товары', |
|
114 | + 'cols' => [ |
|
115 | + 'name', |
|
116 | + 'imgs', |
|
117 | + 'category_id', |
|
118 | + 'item_type_id', |
|
119 | + 'best', |
|
120 | + 'deleted', |
|
121 | + 'options', |
|
122 | + 'offers', |
|
123 | + ], |
|
124 | + 'categorys' => [ |
|
125 | + 'model' => 'Ecommerce\Category', |
|
126 | + ], |
|
127 | + 'sortMode' => true |
|
128 | + ] |
|
129 | + ]; |
|
130 | + public static $forms = [ |
|
131 | + 'manager' => [ |
|
132 | + 'map' => [ |
|
133 | + ['name', 'alias'], |
|
134 | + ['category_id', 'item_type_id', 'deleted'], |
|
135 | + ['widget', 'view'], |
|
136 | + ['best', 'image_file_id'], |
|
137 | + ['description'], |
|
138 | + ['imgs'], |
|
139 | + ['options'], |
|
140 | + ['offers'], |
|
141 | + ] |
|
142 | + ], |
|
143 | + 'simpleItem' => [ |
|
144 | + 'options' => [ |
|
145 | + 'access' => [ |
|
146 | + 'groups' => [ |
|
147 | + 3 |
|
148 | + ] |
|
149 | + ], |
|
150 | + ], |
|
151 | + 'name' => 'Простой товар с ценой', |
|
152 | + 'inputs' => [ |
|
153 | + 'name' => ['type' => 'text'], |
|
154 | + 'description' => ['type' => 'html'], |
|
155 | + 'category' => ['type' => 'select', 'source' => 'model', 'model' => 'Ecommerce\Category', 'label' => 'Категория'], |
|
156 | + 'image' => ['type' => 'image', 'label' => 'Изображение'], |
|
157 | + 'price' => ['type' => 'text', 'label' => 'Цена'], |
|
158 | + 'currency' => ['type' => 'select', 'source' => 'model', 'model' => 'Money\Currency', 'label' => 'Валюта'], |
|
159 | + 'options' => ['type' => 'dynamicList', 'source' => 'options', 'options' => [ |
|
160 | + 'inputs' => [ |
|
161 | + 'option' => ['type' => 'select', 'source' => 'model', 'model' => 'Ecommerce\Item\Option', 'label' => 'Свойство'], |
|
162 | + 'value' => ['type' => 'dynamicType', 'typeSource' => 'selfMethod', 'selfMethod' => 'realType', 'label' => 'Значение'], |
|
163 | + ] |
|
164 | + ] |
|
165 | + ], |
|
166 | + 'offerOptions' => ['type' => 'dynamicList', 'source' => 'options', 'options' => [ |
|
167 | + 'inputs' => [ |
|
168 | + 'option' => ['type' => 'select', 'source' => 'model', 'model' => 'Ecommerce\Item\Offer\Option', 'label' => 'Свойство предложения'], |
|
169 | + 'value' => ['type' => 'dynamicType', 'typeSource' => 'selfMethod', 'selfMethod' => 'realType', 'label' => 'Значение'], |
|
170 | + ] |
|
171 | + ],'label'=>'Параметры предложения' |
|
172 | + ] |
|
173 | + ], |
|
174 | + 'map' => [ |
|
175 | + ['name', 'category'], |
|
176 | + ['description'], |
|
177 | + ['image'], |
|
178 | + ['price', 'currency'], |
|
179 | + ['options'], |
|
180 | + ['offerOptions'], |
|
181 | + ], |
|
182 | + 'handler' => 'simpleItemHandler' |
|
183 | + ] |
|
184 | + ]; |
|
185 | 185 | |
186 | - public function realType() { |
|
186 | + public function realType() { |
|
187 | 187 | if ($this->option && $this->option->type) { |
188 | - $type = $this->option->type; |
|
188 | + $type = $this->option->type; |
|
189 | 189 | |
190 | - if ($type == 'select') { |
|
190 | + if ($type == 'select') { |
|
191 | 191 | return [ |
192 | 192 | 'type' => 'select', |
193 | 193 | 'source' => 'relation', |
194 | 194 | 'relation' => 'option:items', |
195 | 195 | ]; |
196 | - } |
|
197 | - return $type; |
|
196 | + } |
|
197 | + return $type; |
|
198 | 198 | } |
199 | 199 | return 'text'; |
200 | - } |
|
200 | + } |
|
201 | 201 | |
202 | - public static function indexes() { |
|
202 | + public static function indexes() { |
|
203 | 203 | return [ |
204 | 204 | 'ecommerce_item_item_category_id' => [ |
205 | 205 | 'type' => 'INDEX', |
@@ -220,45 +220,45 @@ discard block |
||
220 | 220 | ] |
221 | 221 | ], |
222 | 222 | ]; |
223 | - } |
|
223 | + } |
|
224 | 224 | |
225 | - public function beforeSave() { |
|
225 | + public function beforeSave() { |
|
226 | 226 | |
227 | 227 | if ($this->id) { |
228 | - $this->search_index = $this->name . ' '; |
|
229 | - if ($this->category) { |
|
228 | + $this->search_index = $this->name . ' '; |
|
229 | + if ($this->category) { |
|
230 | 230 | $this->search_index .= $this->category->name . ' '; |
231 | - } |
|
232 | - if ($this->options) { |
|
231 | + } |
|
232 | + if ($this->options) { |
|
233 | 233 | foreach ($this->options as $option) { |
234 | - if ($option->item_option_searchable && $option->value) { |
|
234 | + if ($option->item_option_searchable && $option->value) { |
|
235 | 235 | if ($option->item_option_type != 'select') { |
236 | - $this->search_index .= $option->value . ' '; |
|
236 | + $this->search_index .= $option->value . ' '; |
|
237 | 237 | } elseif (!empty($option->option->items[$option->value])) { |
238 | - $option->option->items[$option->value]->value . ' '; |
|
238 | + $option->option->items[$option->value]->value . ' '; |
|
239 | 239 | } |
240 | - } |
|
240 | + } |
|
241 | + } |
|
241 | 242 | } |
242 | - } |
|
243 | - if ($this->offers) { |
|
243 | + if ($this->offers) { |
|
244 | 244 | foreach ($this->offers as $offer) { |
245 | - if ($offer->options) { |
|
245 | + if ($offer->options) { |
|
246 | 246 | foreach ($offer->options as $option) { |
247 | - if ($option->item_offer_option_searchable && $option->value) { |
|
247 | + if ($option->item_offer_option_searchable && $option->value) { |
|
248 | 248 | if ($option->item_offer_option_type != 'select') { |
249 | - $this->search_index .= $option->value . ' '; |
|
249 | + $this->search_index .= $option->value . ' '; |
|
250 | 250 | } elseif (!empty($option->option->items[$option->value])) { |
251 | - $option->option->items[$option->value]->value . ' '; |
|
251 | + $option->option->items[$option->value]->value . ' '; |
|
252 | 252 | } |
253 | - } |
|
253 | + } |
|
254 | + } |
|
254 | 255 | } |
255 | - } |
|
256 | 256 | } |
257 | - } |
|
257 | + } |
|
258 | + } |
|
258 | 259 | } |
259 | - } |
|
260 | 260 | |
261 | - public static function relations() { |
|
261 | + public static function relations() { |
|
262 | 262 | |
263 | 263 | return [ |
264 | 264 | 'category' => [ |
@@ -296,55 +296,55 @@ discard block |
||
296 | 296 | 'col' => 'user_id' |
297 | 297 | ] |
298 | 298 | ]; |
299 | - } |
|
299 | + } |
|
300 | 300 | |
301 | - public function getPrice() { |
|
301 | + public function getPrice() { |
|
302 | 302 | $offers = $this->offers(['key' => false]); |
303 | 303 | $curPrice = null; |
304 | 304 | |
305 | 305 | foreach ($offers[0]->prices as $price) { |
306 | - if (!$price->type) { |
|
306 | + if (!$price->type) { |
|
307 | 307 | $curPrice = $price; |
308 | - } elseif ( |
|
309 | - (!$price->type->roles && !$curPrice) || |
|
308 | + } elseif ( |
|
309 | + (!$price->type->roles && !$curPrice) || |
|
310 | 310 | ($price->type->roles && !$curPrice && strpos($price->type->roles, "|" . \Users\User::$cur->role_id . "|") !== false) |
311 | - ) { |
|
311 | + ) { |
|
312 | 312 | $curPrice = $price; |
313 | - } |
|
313 | + } |
|
314 | 314 | } |
315 | 315 | return $curPrice; |
316 | - } |
|
316 | + } |
|
317 | 317 | |
318 | - public function name() { |
|
318 | + public function name() { |
|
319 | 319 | if (!empty(\App::$primary->ecommerce->config['item_option_as_name'])) { |
320 | - $param = Item\Param::get([['item_id', $this->id], ['item_option_id', \App::$primary->ecommerce->config['item_option_as_name']]]); |
|
321 | - if ($param && $param->value) { |
|
320 | + $param = Item\Param::get([['item_id', $this->id], ['item_option_id', \App::$primary->ecommerce->config['item_option_as_name']]]); |
|
321 | + if ($param && $param->value) { |
|
322 | 322 | return $param->value; |
323 | - } |
|
323 | + } |
|
324 | 324 | } |
325 | 325 | return $this->name; |
326 | - } |
|
326 | + } |
|
327 | 327 | |
328 | - public function beforeDelete() { |
|
328 | + public function beforeDelete() { |
|
329 | 329 | if ($this->id) { |
330 | - if ($this->options) { |
|
330 | + if ($this->options) { |
|
331 | 331 | foreach ($this->options as $option) { |
332 | - $option->delete(); |
|
332 | + $option->delete(); |
|
333 | + } |
|
333 | 334 | } |
334 | - } |
|
335 | - if ($this->offers) { |
|
335 | + if ($this->offers) { |
|
336 | 336 | foreach ($this->offers as $offer) { |
337 | - $offer->delete(); |
|
337 | + $offer->delete(); |
|
338 | 338 | } |
339 | - } |
|
340 | - if ($this->image) { |
|
339 | + } |
|
340 | + if ($this->image) { |
|
341 | 341 | $this->image->delete(); |
342 | - } |
|
342 | + } |
|
343 | + } |
|
343 | 344 | } |
344 | - } |
|
345 | 345 | |
346 | - public function getHref() { |
|
346 | + public function getHref() { |
|
347 | 347 | return "/ecommerce/view/{$this->pk()}"; |
348 | - } |
|
348 | + } |
|
349 | 349 | |
350 | 350 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'size' => $_FILES['ActiveForm_simpleItem']['size']['Ecommerce\Item']['image'], |
72 | 72 | 'error' => $_FILES['ActiveForm_simpleItem']['error']['Ecommerce\Item']['image'], |
73 | 73 | ], [ |
74 | - 'upload_code' => 'activeForm:' . 'Ecommerce\Item' . ':' . $item->pk(), |
|
74 | + 'upload_code' => 'activeForm:'.'Ecommerce\Item'.':'.$item->pk(), |
|
75 | 75 | 'accept_group' => 'image' |
76 | 76 | ]); |
77 | 77 | if ($file_id) { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | 'option' => ['type' => 'select', 'source' => 'model', 'model' => 'Ecommerce\Item\Offer\Option', 'label' => 'Свойство предложения'], |
169 | 169 | 'value' => ['type' => 'dynamicType', 'typeSource' => 'selfMethod', 'selfMethod' => 'realType', 'label' => 'Значение'], |
170 | 170 | ] |
171 | - ],'label'=>'Параметры предложения' |
|
171 | + ], 'label'=>'Параметры предложения' |
|
172 | 172 | ] |
173 | 173 | ], |
174 | 174 | 'map' => [ |
@@ -225,17 +225,17 @@ discard block |
||
225 | 225 | public function beforeSave() { |
226 | 226 | |
227 | 227 | if ($this->id) { |
228 | - $this->search_index = $this->name . ' '; |
|
228 | + $this->search_index = $this->name.' '; |
|
229 | 229 | if ($this->category) { |
230 | - $this->search_index .= $this->category->name . ' '; |
|
230 | + $this->search_index .= $this->category->name.' '; |
|
231 | 231 | } |
232 | 232 | if ($this->options) { |
233 | 233 | foreach ($this->options as $option) { |
234 | 234 | if ($option->item_option_searchable && $option->value) { |
235 | 235 | if ($option->item_option_type != 'select') { |
236 | - $this->search_index .= $option->value . ' '; |
|
236 | + $this->search_index .= $option->value.' '; |
|
237 | 237 | } elseif (!empty($option->option->items[$option->value])) { |
238 | - $option->option->items[$option->value]->value . ' '; |
|
238 | + $option->option->items[$option->value]->value.' '; |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | } |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | foreach ($offer->options as $option) { |
247 | 247 | if ($option->item_offer_option_searchable && $option->value) { |
248 | 248 | if ($option->item_offer_option_type != 'select') { |
249 | - $this->search_index .= $option->value . ' '; |
|
249 | + $this->search_index .= $option->value.' '; |
|
250 | 250 | } elseif (!empty($option->option->items[$option->value])) { |
251 | - $option->option->items[$option->value]->value . ' '; |
|
251 | + $option->option->items[$option->value]->value.' '; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | 'col' => 'item_id', |
272 | 272 | //'resultKey' => 'code', |
273 | 273 | 'resultKey' => 'item_option_id', |
274 | - 'join' => [Item\Option::table(), Item\Option::index() . ' = ' . Item\Param::colPrefix() . Item\Option::index()] |
|
274 | + 'join' => [Item\Option::table(), Item\Option::index().' = '.Item\Param::colPrefix().Item\Option::index()] |
|
275 | 275 | ], |
276 | 276 | 'offers' => [ |
277 | 277 | 'type' => 'many', |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $curPrice = $price; |
308 | 308 | } elseif ( |
309 | 309 | (!$price->type->roles && !$curPrice) || |
310 | - ($price->type->roles && !$curPrice && strpos($price->type->roles, "|" . \Users\User::$cur->role_id . "|") !== false) |
|
310 | + ($price->type->roles && !$curPrice && strpos($price->type->roles, "|".\Users\User::$cur->role_id."|") !== false) |
|
311 | 311 | ) { |
312 | 312 | $curPrice = $price; |
313 | 313 | } |