diff --git a/common/modules/product/models/Export.php b/common/modules/product/models/Export.php index f276307..dae6840 100755 --- a/common/modules/product/models/Export.php +++ b/common/modules/product/models/Export.php @@ -16,7 +16,7 @@ if(is_null($filename)) { $filename = 'products_' . date('d_m_Y_H_i') . '.csv'; } -// setlocale(LC_ALL, 'ru_RU.UTF-8'); + setlocale(LC_ALL, 'ru_RU.CP1251'); $handle = fopen($dirName . '/' . $filename, "w"); $products = Product::find() ->joinWith([ @@ -47,7 +47,7 @@ $list = [ $categories, - (!empty($product->brand->name) ? $product->brand->name : ''), + (!empty($product->size) ? $product->size : ''), $product->name, '', ( ( !empty( $product->description ) ) ? $product->description : '' ), @@ -62,7 +62,9 @@ implode(',', $fotos), ]; $to_write = array_merge($list, $mods); - + foreach($to_write as &$cell) { + $cell = iconv("UTF-8", "WINDOWS-1251", $cell); + } fputcsv($handle, $to_write, ';'); unset( $product ); } diff --git a/common/modules/product/models/Import.php b/common/modules/product/models/Import.php index 795c79d..45129a3 100755 --- a/common/modules/product/models/Import.php +++ b/common/modules/product/models/Import.php @@ -205,8 +205,8 @@ class Import extends Model { continue; } - // 2 Бренд - $brand_name = $data[1]; + // 2 Размер (кастомное поле для Баккары) + $product_size = $data[1]; // if (empty ($brand_name)) // { // $result_items[] = "Не указан бренд (строка $j)"; @@ -286,20 +286,20 @@ class Import extends Model { $_product->categories = $category_id; // ===== Set brand ==== - if ( $brand_name ) { - /** - * @var Brand $brand - */ - if ( ($brand = Brand::find()->filterWhere(['ilike', 'name', trim($brand_name)])->one()) !== null ) { - $_product->brand_id = $brand->brand_id; - } else { - // Create brand - $brand = new Brand(); - $brand->name = trim($brand_name); - $brand->save(); - $_product->brand_id = $brand->brand_id; - } - } +// if ( $brand_name ) { +// /** +// * @var Brand $brand +// */ +// if ( ($brand = Brand::find()->filterWhere(['ilike', 'name', trim($brand_name)])->one()) !== null ) { +// $_product->brand_id = $brand->brand_id; +// } else { +// // Create brand +// $brand = new Brand(); +// $brand->name = trim($brand_name); +// $brand->save(); +// $_product->brand_id = $brand->brand_id; +// } +// } $_product->name = $product_name; $_product->video = $product_video; @@ -307,6 +307,7 @@ class Import extends Model { $_product->is_top = $product_top; $_product->akciya = $product_akciya; $_product->is_new = $product_new; + $_product->size = $product_size; if (!$_product->save()) { $result_items[] = 'Product #'. $_product->name .' not saved' . " (строка $j)"; -- libgit2 0.21.4