Commit d5237e4898ca2026db8c0b5f8c4bf979cde3f087
1 parent
b8a993f6
-Export/Import Baccara customization
Showing
2 changed files
with
22 additions
and
19 deletions
Show diff stats
common/modules/product/models/Export.php
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | if(is_null($filename)) { |
17 | 17 | $filename = 'products_' . date('d_m_Y_H_i') . '.csv'; |
18 | 18 | } |
19 | -// setlocale(LC_ALL, 'ru_RU.UTF-8'); | |
19 | + setlocale(LC_ALL, 'ru_RU.CP1251'); | |
20 | 20 | $handle = fopen($dirName . '/' . $filename, "w"); |
21 | 21 | $products = Product::find() |
22 | 22 | ->joinWith([ |
... | ... | @@ -47,7 +47,7 @@ |
47 | 47 | |
48 | 48 | $list = [ |
49 | 49 | $categories, |
50 | - (!empty($product->brand->name) ? $product->brand->name : ''), | |
50 | + (!empty($product->size) ? $product->size : ''), | |
51 | 51 | $product->name, |
52 | 52 | '', |
53 | 53 | ( ( !empty( $product->description ) ) ? $product->description : '' ), |
... | ... | @@ -62,7 +62,9 @@ |
62 | 62 | implode(',', $fotos), |
63 | 63 | ]; |
64 | 64 | $to_write = array_merge($list, $mods); |
65 | - | |
65 | + foreach($to_write as &$cell) { | |
66 | + $cell = iconv("UTF-8", "WINDOWS-1251", $cell); | |
67 | + } | |
66 | 68 | fputcsv($handle, $to_write, ';'); |
67 | 69 | unset( $product ); |
68 | 70 | } | ... | ... |
common/modules/product/models/Import.php
... | ... | @@ -205,8 +205,8 @@ class Import extends Model { |
205 | 205 | continue; |
206 | 206 | } |
207 | 207 | |
208 | - // 2 Бренд | |
209 | - $brand_name = $data[1]; | |
208 | + // 2 Размер (кастомное поле для Баккары) | |
209 | + $product_size = $data[1]; | |
210 | 210 | // if (empty ($brand_name)) |
211 | 211 | // { |
212 | 212 | // $result_items[] = "Не указан бренд (строка $j)"; |
... | ... | @@ -286,20 +286,20 @@ class Import extends Model { |
286 | 286 | $_product->categories = $category_id; |
287 | 287 | |
288 | 288 | // ===== Set brand ==== |
289 | - if ( $brand_name ) { | |
290 | - /** | |
291 | - * @var Brand $brand | |
292 | - */ | |
293 | - if ( ($brand = Brand::find()->filterWhere(['ilike', 'name', trim($brand_name)])->one()) !== null ) { | |
294 | - $_product->brand_id = $brand->brand_id; | |
295 | - } else { | |
296 | - // Create brand | |
297 | - $brand = new Brand(); | |
298 | - $brand->name = trim($brand_name); | |
299 | - $brand->save(); | |
300 | - $_product->brand_id = $brand->brand_id; | |
301 | - } | |
302 | - } | |
289 | +// if ( $brand_name ) { | |
290 | +// /** | |
291 | +// * @var Brand $brand | |
292 | +// */ | |
293 | +// if ( ($brand = Brand::find()->filterWhere(['ilike', 'name', trim($brand_name)])->one()) !== null ) { | |
294 | +// $_product->brand_id = $brand->brand_id; | |
295 | +// } else { | |
296 | +// // Create brand | |
297 | +// $brand = new Brand(); | |
298 | +// $brand->name = trim($brand_name); | |
299 | +// $brand->save(); | |
300 | +// $_product->brand_id = $brand->brand_id; | |
301 | +// } | |
302 | +// } | |
303 | 303 | |
304 | 304 | $_product->name = $product_name; |
305 | 305 | $_product->video = $product_video; |
... | ... | @@ -307,6 +307,7 @@ class Import extends Model { |
307 | 307 | $_product->is_top = $product_top; |
308 | 308 | $_product->akciya = $product_akciya; |
309 | 309 | $_product->is_new = $product_new; |
310 | + $_product->size = $product_size; | |
310 | 311 | |
311 | 312 | if (!$_product->save()) { |
312 | 313 | $result_items[] = 'Product #'. $_product->name .' not saved' . " (строка $j)"; | ... | ... |