|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Item images parser |
|
5
|
|
|
* |
|
6
|
|
|
* @author Alexey Krupskiy <[email protected]> |
|
7
|
|
|
* @link http://inji.ru/ |
|
8
|
|
|
* @copyright 2016 Alexey Krupskiy |
|
9
|
|
|
* @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Exchange1c\Parser\Item; |
|
13
|
|
|
|
|
14
|
|
|
class Options extends \Migrations\Parser { |
|
15
|
|
|
|
|
16
|
|
|
public static $options; |
|
17
|
|
|
|
|
18
|
|
|
public function parse() { |
|
19
|
|
|
if (!Options::$options) { |
|
20
|
|
|
Options::$options = \Ecommerce\Item\Option::getList(); |
|
|
|
|
|
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
if (!empty($this->data['ЗначенияСвойства'])) { |
|
24
|
|
|
if (\Tools::isAssoc($this->data['ЗначенияСвойства'])) { |
|
|
|
|
|
|
25
|
|
|
$data = [$this->data['ЗначенияСвойства']]; |
|
26
|
|
|
} else { |
|
27
|
|
|
$data = &$this->data['ЗначенияСвойства']; |
|
28
|
|
|
} |
|
29
|
|
|
} else { |
|
30
|
|
|
$data = []; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
$options = []; |
|
35
|
|
|
$itemParams = \Ecommerce\Item\Param::getList(['where' => ['item_id', $this->model->id],'key'=>'item_option_id']); |
|
|
|
|
|
|
36
|
|
|
foreach ($this->object->object->params as $param) { |
|
37
|
|
|
if ($param->type == 'paramValue' && isset($itemParams[$param->value])) { |
|
38
|
|
|
$options[$param->value] = $itemParams[$param->value]->value; |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
foreach ($data as $opt) { |
|
42
|
|
|
if (empty($opt['Ид'])) { |
|
43
|
|
|
var_dump($data, $opt); |
|
|
|
|
|
|
44
|
|
|
exit(); |
|
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
$optionId = \App::$cur->migrations->findObject($opt['Ид'], 'Ecommerce\Item\Option'); |
|
47
|
|
|
if ($optionId) { |
|
48
|
|
|
$optionId = $optionId->object_id; |
|
49
|
|
|
} |
|
50
|
|
|
if ($optionId && !isset(Options::$options[$optionId])) { |
|
51
|
|
|
Options::$options = \Ecommerce\Item\Option::getList(); |
|
52
|
|
|
} |
|
53
|
|
|
if (isset(Options::$options[$optionId]) && Options::$options[$optionId]->type == 'select') { |
|
54
|
|
|
if (empty($options[$optionId])) { |
|
55
|
|
|
$options[$optionId] = []; |
|
56
|
|
|
} else { |
|
57
|
|
|
if (!Options::$options[$optionId]->advance) { |
|
58
|
|
|
Options::$options[$optionId]->advance = ['multi' => true]; |
|
59
|
|
|
Options::$options[$optionId]->save(); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
if ($opt['Значение'] && $value = \App::$cur->migrations->findObject($opt['Значение'], 'Ecommerce\Item\Option\Item')) { |
|
63
|
|
|
$options[$optionId][] = $value->object_id; |
|
64
|
|
|
} |
|
65
|
|
|
} else { |
|
66
|
|
|
$options[$optionId] = $opt['Значение']; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
foreach ($itemParams as $itemParam) { |
|
72
|
|
|
if ($itemParam->item_option_id && !isset(Options::$options[$itemParam->item_option_id])) { |
|
73
|
|
|
Options::$options = \Ecommerce\Item\Option::getList(); |
|
74
|
|
|
} |
|
75
|
|
|
if (isset(Options::$options[$itemParam->item_option_id]) && Options::$options[$itemParam->item_option_id]->type == 'select') { |
|
76
|
|
|
if (empty($options[$itemParam->item_option_id]) || !in_array($itemParam->value, $options[$itemParam->item_option_id])) { |
|
77
|
|
|
$itemParam->delete(); |
|
78
|
|
|
} else { |
|
79
|
|
|
unset($options[$itemParam->item_option_id][array_search($itemParam->value, $options[$itemParam->item_option_id])]); |
|
80
|
|
|
} |
|
81
|
|
|
} else { |
|
82
|
|
|
if (empty($options[$itemParam->item_option_id])) { |
|
83
|
|
|
$itemParam->delete(); |
|
84
|
|
|
} else { |
|
85
|
|
|
$itemParam->value = $options[$itemParam->item_option_id]; |
|
86
|
|
|
$itemParam->save(); |
|
87
|
|
|
unset($options[$itemParam->item_option_id]); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
foreach ($options as $optionId => $values) { |
|
92
|
|
|
if (is_array($values)) { |
|
93
|
|
|
foreach ($values as $value) { |
|
94
|
|
|
$itemParam = new \Ecommerce\Item\Param([ |
|
95
|
|
|
'item_option_id' => $optionId, |
|
96
|
|
|
'item_id' => $this->model->id, |
|
97
|
|
|
'value' => $value |
|
98
|
|
|
]); |
|
99
|
|
|
$itemParam->save(); |
|
100
|
|
|
} |
|
101
|
|
|
} else { |
|
102
|
|
|
$itemParam = new \Ecommerce\Item\Param([ |
|
103
|
|
|
'item_option_id' => $optionId, |
|
104
|
|
|
'item_id' => $this->model->id, |
|
105
|
|
|
'value' => $values |
|
106
|
|
|
]); |
|
107
|
|
|
$itemParam->save(); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths