Commit 096128d989e9d12c55653d649046d2ffa5dcb33f

Authored by Yarik
1 parent 53b71cf4

Import test

common/modules/product/models/Export.php
@@ -59,7 +59,7 @@ @@ -59,7 +59,7 @@
59 $list = [ 59 $list = [
60 $categories, 60 $categories,
61 !empty($product->brand) ? $product->brand ->name :'', 61 !empty($product->brand) ? $product->brand ->name :'',
62 - $product->name, 62 + $product->name . '(#' . $product->product_id .'#)',
63 '', 63 '',
64 ( ( !empty( $product->description ) ) ? $product->description : '' ), 64 ( ( !empty( $product->description ) ) ? $product->description : '' ),
65 $filterString, 65 $filterString,
common/modules/product/models/Import.php
@@ -243,7 +243,6 @@ @@ -243,7 +243,6 @@
243 243
244 public function goProducts($from = 0, $limit = null) 244 public function goProducts($from = 0, $limit = null)
245 { 245 {
246 -  
247 set_time_limit(0); 246 set_time_limit(0);
248 $new_products = $linked_products = 0; 247 $new_products = $linked_products = 0;
249 248
@@ -318,6 +317,12 @@ @@ -318,6 +317,12 @@
318 $result_items[] = "Не указано наименование товара (строка $j)"; 317 $result_items[] = "Не указано наименование товара (строка $j)";
319 continue; 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 // 4 Описание Укр 327 // 4 Описание Укр
323 $product_body_uk = $data[ 3 ]; 328 $product_body_uk = $data[ 3 ];
@@ -363,7 +368,11 @@ @@ -363,7 +368,11 @@
363 $product_image = explode('=', $data[ 14 ]); 368 $product_image = explode('=', $data[ 14 ]);
364 $product_image = @$product_image[ 3 ]; 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 ->filterWhere([ 'name' => trim($product_name) ]) 376 ->filterWhere([ 'name' => trim($product_name) ])
368 ->one() ) === null 377 ->one() ) === null
369 ) { 378 ) {