Commit 096128d989e9d12c55653d649046d2ffa5dcb33f

Authored by Yarik
1 parent 53b71cf4

Import test

common/modules/product/models/Export.php
... ... @@ -59,7 +59,7 @@
59 59 $list = [
60 60 $categories,
61 61 !empty($product->brand) ? $product->brand ->name :'',
62   - $product->name,
  62 + $product->name . '(#' . $product->product_id .'#)',
63 63 '',
64 64 ( ( !empty( $product->description ) ) ? $product->description : '' ),
65 65 $filterString,
... ...
common/modules/product/models/Import.php
... ... @@ -243,7 +243,6 @@
243 243  
244 244 public function goProducts($from = 0, $limit = null)
245 245 {
246   -
247 246 set_time_limit(0);
248 247 $new_products = $linked_products = 0;
249 248  
... ... @@ -318,6 +317,12 @@
318 317 $result_items[] = "Не указано наименование товара (строка $j)";
319 318 continue;
320 319 }
  320 + if(preg_match('/^.+\(#(\d+)#\)$/', trim($product_name), $remote_id)) {
  321 + if(!empty($remote_id[1])) {
  322 + $remote_id = $remote_id[1];
  323 + $product_name = substr($product_name, 0, strpos($product_name, '(#' . $remote_id . '#)'));
  324 + }
  325 + }
321 326  
322 327 // 4 Описание Укр
323 328 $product_body_uk = $data[ 3 ];
... ... @@ -363,7 +368,11 @@
363 368 $product_image = explode('=', $data[ 14 ]);
364 369 $product_image = @$product_image[ 3 ];
365 370  
366   - if (( $_product = Product::find()
  371 + if(!empty($remote_id)) {
  372 + if(($_product = Product::find()->filterWhere(['product_id' => $remote_id])->one()) === null) {
  373 + $_product = new Product();
  374 + }
  375 + } elseif (( $_product = Product::find()
367 376 ->filterWhere([ 'name' => trim($product_name) ])
368 377 ->one() ) === null
369 378 ) {
... ...