Commit 3da8b25f470f1b7624991e13f878e72653e5a937
1 parent
53eb6c31
fixed issues with details trigger and with remove prefix func
Showing
5 changed files
with
14 additions
and
10 deletions
Show diff stats
backend/controllers/ParserController.php
... | ... | @@ -200,7 +200,9 @@ class ParserController extends BaseController |
200 | 200 | Yii::$app->getCache()->delete('parser_data'); |
201 | 201 | Yii::$app->getCache()->delete('parser_configuration'); |
202 | 202 | |
203 | - unlink($configuration['file_path']); | |
203 | + if( file_exists($configuration['file_path']) ) | |
204 | + unlink($configuration['file_path']); | |
205 | + | |
204 | 206 | return $this->render('index', ['model' => $configuration]); |
205 | 207 | |
206 | 208 | }; | ... | ... |
common/components/parsers/CustomConverter.php
... | ... | @@ -18,6 +18,7 @@ class CustomConverter extends Converter |
18 | 18 | public static $sign; |
19 | 19 | public static $multiplier; |
20 | 20 | public static $importer_id; |
21 | + public static $brand; | |
21 | 22 | |
22 | 23 | public static function convertToAssocArray(array $value_arr, array $key_array, $key_prefix = '') |
23 | 24 | { |
... | ... | @@ -160,11 +161,12 @@ class CustomConverter extends Converter |
160 | 161 | |
161 | 162 | if( isset( $row['BRAND'] ) && isset( self::$importer_id ) ){ |
162 | 163 | // 2. Уберем брендовый префикс (если он есть) |
164 | + self::$brand = $row['BRAND']; | |
163 | 165 | $prefix = ''; |
164 | 166 | // запрос закешируем |
165 | - $prefix = ImportersPrefix::getDb()->cache( function ($db, $configuration, $row ) { | |
167 | + $prefix = ImportersPrefix::getDb()->cache( function ($db) { | |
166 | 168 | return ImportersPrefix::find()->where([ 'importer_id' => self::$importer_id, |
167 | - 'brand' => $row['BRAND'] ])->one(); | |
169 | + 'brand' => self::$brand ])->one(); | |
168 | 170 | }); |
169 | 171 | |
170 | 172 | if ($prefix) { |
... | ... | @@ -187,7 +189,7 @@ class CustomConverter extends Converter |
187 | 189 | |
188 | 190 | public static function convertToBrand($value) |
189 | 191 | { |
190 | - $res = $value; | |
192 | + $res = parent::convertToEncode($value);; | |
191 | 193 | $res = trim(strtoupper($res)); |
192 | 194 | $res = str_replace("Ä", "A", str_replace("Ö", "O", str_replace("Ü", "U", str_replace("Ë", "E", str_replace("Ò", "O", $res))))); |
193 | 195 | $res = str_replace(array('@', '#', '~', '"', "'", "?", "!"), '', $res); |
... | ... | @@ -197,7 +199,7 @@ class CustomConverter extends Converter |
197 | 199 | |
198 | 200 | public static function convertToString($value) |
199 | 201 | { |
200 | - $value = parent::convertToString($value); | |
202 | + $value = parent::convertToEncode($value); | |
201 | 203 | |
202 | 204 | return str_replace(array('!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '=', '-', '~', '`', '"', "'", ' ', '№', '%', ';', ':', '[', ']', '{', '}', '*', '?', '/', '\'', '|', '.', ',', '<', '>', '\\'), '', $value); |
203 | 205 | } | ... | ... |
common/components/parsers/config.php
... | ... | @@ -5,8 +5,8 @@ |
5 | 5 | ['class' => 'common\components\parsers\CustomCsvParser', |
6 | 6 | 'auto_detect_first_line' => true, |
7 | 7 | 'converter_conf' => [ |
8 | - //'class' => ' common\components\parsers\CustomConverter', // @todo переделать на подключаемый behavior | |
9 | - 'configuration' => ["string" => 'DESCR'],] | |
8 | + //'class' => ' common\components\parsers\CustomConverter', // @todo переделать на компонент | |
9 | + 'configuration' => ["encode" => 'DESCR'],] | |
10 | 10 | ], |
11 | 11 | 'console' => |
12 | 12 | ['class' => 'common\components\parsers\CustomCsvParser', | ... | ... |
console/migrations/m151016_090927_editDetailsTrigger.php
... | ... | @@ -41,9 +41,9 @@ class m151016_090927_editDetailsTrigger extends Migration |
41 | 41 | |
42 | 42 | SET vBrand = ''; |
43 | 43 | |
44 | - SELECT to_name, to_brand INTO vArticle, vBrand from w_details_replace where from_name = NEW.ARTICLE AND from_brand = NEW.BRAND; | |
44 | + SELECT to_name, to_brand INTO vArticle, vBrand from w_details_replace where from_name = NEW.ARTICLE AND from_brand = NEW.BRAND LIMIT 1; | |
45 | 45 | |
46 | - IF vArticle != '' AND vArticle != NULL then | |
46 | + IF vArticle != '' then | |
47 | 47 | SET NEW.BRAND = vBrand; |
48 | 48 | SET NEW.ARTICLE = vArticle; |
49 | 49 | end if; | ... | ... |
vendor/yiisoft/multiparser/Converter.php