-
Notifications
You must be signed in to change notification settings - Fork 1
/
Exchange1cModule.php
172 lines (149 loc) · 4.11 KB
/
Exchange1cModule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
use yupe\components\WebModule;
class Exchange1cModule extends WebModule
{
public $folderFiles = '/uploads/files/prices';
public $readFileProducts = 'goods.csv';
public $readFileCategory = 'category.csv';
public $columnSeparator = ';';
public $arrayCorrespondences = [
'Producer'=> [
// 'id' => '',
'id_1c' => '{6}',
'name_short' => '{7:string}',
'name' => '{7}',
'slug' => '{7}',
'status' => '1',
],
'StoreCategory' => [
'id_1c' => '{0:int}',
'name' => '{1}',
'alias' => '{1}',
'status' => '1',
'sort' => '{0:int}',
],
'Product' => [
'id_1c' => '{2:int}',
'category_id' => '{0:int}',
'name' => '{3}',
'quantity' => '{11}',
'image' => '{2:int}.{12}',
'status' => '1',
'is_special' => '0',
'in_stock' => '1',
'price' => '{10:int}',
'short_description' => 'Артикул: {5}; Производитель: {7} {4}',
'description' => '{13}',
'slug' => '{3}', // URL
]
];
const VERSION = '0.1';
public function getVersion()
{
return self::VERSION;
}
public function getDependencies()
{
return [
'store',
];
}
/*public function getCategory()
{
return Yii::t('Exchange1cModule.main', 'Catalog');
}*/
public function getName()
{
return Yii::t('Exchange1cModule.main', 'Exchange 1c');
}
public function getDescription()
{
return Yii::t('Exchange1cModule.main', 'The module updates the database of the store unloaded files 1c');
}
public function getAuthor()
{
return Yii::t('Exchange1cModule.main', 'UnnamedTeam');
}
public function getAuthorEmail()
{
return Yii::t('Exchange1cModule.main', '[email protected]');
}
public function getIcon()
{
return "glyphicon glyphicon-sort";
}
public function getNavigation()
{
return [
[
'label' => Yii::t('Exchange1cModule.main', 'Справка'),
'url' => ['/backend/exchange1c/exchange/help'],
'icon' => "fa fa-fw fa-question-circle",
]
];
}
public function checkSelf()
{
$messages = [];
$readableFile = Yii::getPathOfAlias('webroot');
$readableFile = $readableFile.$this->folderFiles;
$readFileProducts = $readableFile.'/'.$this->readFileProducts;
$readFileCategory = $readableFile.'/'.$this->readFileCategory;
if (!file_exists($readableFile)) {
$messages[WebModule::CHECK_ERROR][] = [
'type' => WebModule::CHECK_ERROR,
'message' => 'Директория '.$readableFile.' не существует'
];
}
if (!file_exists($readFileProducts)) {
$messages[WebModule::CHECK_ERROR][] = [
'type' => WebModule::CHECK_ERROR,
'message' => 'Файл '.$readFileProducts.' не существует'
];
}
if (!file_exists($readFileCategory)) {
$messages[WebModule::CHECK_ERROR][] = [
'type' => WebModule::CHECK_NOTICE,
'message' => 'Файл '.$readFileCategory.' не существует'
];
}
return isset($messages[WebModule::CHECK_ERROR]) ? $messages : true;
}
public function getEditableParams()
{
return [
'folderFiles',
'readFileProducts',
'readFileCategory',
'columnSeparator',
];
}
public function getParamsLabels()
{
return [
'folderFiles' =>'Папка файлов выгрузки',
'readFileProducts'=>'Файл с выгруженными товарами',
'readFileCategory'=>'Файл с выгруженными категориями',
'columnSeparator' =>'Разделитель колонок',
];
}
public function init()
{
$this->setImport(array(
'exchange1c.models.*',
'exchange1c.components.*',
));
parent::init();
}
public function beforeControllerAction($controller, $action)
{
if(parent::beforeControllerAction($controller, $action))
{
// this method is called before any module controller action is performed
// you may place customized code here
return true;
}
else
return false;
}
}