diff --git a/common/modules/product/models/Export.php b/common/modules/product/models/Export.php index cc0736a..42b69a7 100644 --- a/common/modules/product/models/Export.php +++ b/common/modules/product/models/Export.php @@ -59,7 +59,7 @@ $list = [ $categories, !empty($product->brand) ? $product->brand ->name :'', - $product->name, + $product->name . '(#' . $product->product_id .'#)', '', ( ( !empty( $product->description ) ) ? $product->description : '' ), $filterString, diff --git a/common/modules/product/models/Import.php b/common/modules/product/models/Import.php index fa8a843..6395ecc 100755 --- a/common/modules/product/models/Import.php +++ b/common/modules/product/models/Import.php @@ -243,7 +243,6 @@ public function goProducts($from = 0, $limit = null) { - set_time_limit(0); $new_products = $linked_products = 0; @@ -318,6 +317,12 @@ $result_items[] = "Не указано наименование товара (строка $j)"; continue; } + if(preg_match('/^.+\(#(\d+)#\)$/', trim($product_name), $remote_id)) { + if(!empty($remote_id[1])) { + $remote_id = $remote_id[1]; + $product_name = substr($product_name, 0, strpos($product_name, '(#' . $remote_id . '#)')); + } + } // 4 Описание Укр $product_body_uk = $data[ 3 ]; @@ -363,7 +368,11 @@ $product_image = explode('=', $data[ 14 ]); $product_image = @$product_image[ 3 ]; - if (( $_product = Product::find() + if(!empty($remote_id)) { + if(($_product = Product::find()->filterWhere(['product_id' => $remote_id])->one()) === null) { + $_product = new Product(); + } + } elseif (( $_product = Product::find() ->filterWhere([ 'name' => trim($product_name) ]) ->one() ) === null ) { -- libgit2 0.21.4