Commit 6583ee6b820956456fe65236613a2186c00a6c19
1 parent
5b7adec0
big commti
Showing
1 changed file
with
16 additions
and
20 deletions
Show diff stats
common/modules/product/models/Export.php
@@ -18,24 +18,23 @@ class Export extends Model { | @@ -18,24 +18,23 @@ class Export extends Model { | ||
18 | $handle = fopen($dirName .'/'. $filename, "w"); | 18 | $handle = fopen($dirName .'/'. $filename, "w"); |
19 | ///$products = Product::find()->joinWith(['variants'])->where(['!=', ProductVariant::tableName() .'.stock', 0])->select('product.product_id')->all(); | 19 | ///$products = Product::find()->joinWith(['variants'])->where(['!=', ProductVariant::tableName() .'.stock', 0])->select('product.product_id')->all(); |
20 | $products = Product::find() | 20 | $products = Product::find() |
21 | - ->with(['variantsWithFilters','brand','categories','filters'])->all(); | 21 | + ->joinWith(['variantsWithFilters','brand','categories'])->with('filters')->all(); |
22 | 22 | ||
23 | 23 | ||
24 | 24 | ||
25 | - $count = count($products); | ||
26 | - for ($i=0; $i<=$count; $i++) | 25 | + foreach ($products as $product) |
27 | { | 26 | { |
28 | 27 | ||
29 | 28 | ||
30 | - $i++; | 29 | + |
31 | /*if ($i>1e2) { | 30 | /*if ($i>1e2) { |
32 | break; | 31 | break; |
33 | }*/ | 32 | }*/ |
34 | $mods = []; | 33 | $mods = []; |
35 | 34 | ||
36 | - $filterString = $this->convertFilterToString($products[$i]->filters); | 35 | + $filterString = $this->convertFilterToString($product->filters); |
37 | 36 | ||
38 | - foreach ($products[$i]->variantsWithFilters as $variant) | 37 | + foreach ($product->variantsWithFilters as $variant) |
39 | { | 38 | { |
40 | 39 | ||
41 | $color = $variant->name; | 40 | $color = $variant->name; |
@@ -57,7 +56,7 @@ class Export extends Model { | @@ -57,7 +56,7 @@ class Export extends Model { | ||
57 | 56 | ||
58 | // $filters = $product->properties; | 57 | // $filters = $product->properties; |
59 | $categories = []; | 58 | $categories = []; |
60 | - foreach($products[$i]->categories as $value){ | 59 | + foreach($product->categories as $value){ |
61 | 60 | ||
62 | $categories[] = $value->name; | 61 | $categories[] = $value->name; |
63 | 62 | ||
@@ -69,18 +68,18 @@ class Export extends Model { | @@ -69,18 +68,18 @@ class Export extends Model { | ||
69 | $list = [ | 68 | $list = [ |
70 | 69 | ||
71 | $categories, | 70 | $categories, |
72 | - $products[$i]->brand->name, | ||
73 | - $products[$i]->name, | 71 | + $product->brand->name, |
72 | + $product->name, | ||
74 | '', | 73 | '', |
75 | - ((! empty($products[$i]->description)) ? $products[$i]->description : ''), | 74 | + ((! empty($product->description)) ? $product->description : ''), |
76 | $filterString, | 75 | $filterString, |
77 | - (!empty($products[$i]->variant)) ? $products[$i]->variant->price_old : '', | ||
78 | - (!empty($products[$i]->variant)) ? $products[$i]->variant->price : '', | ||
79 | - intval($products[$i]->akciya), | 76 | + (!empty($product->variant)) ? $product->variant->price_old : '', |
77 | + (!empty($product->variant)) ? $product->variant->price : '', | ||
78 | + intval($product->akciya), | ||
80 | '', | 79 | '', |
81 | - intval($products[$i]->is_new), | ||
82 | - intval($products[$i]->is_top), | ||
83 | - $products[$i]->video, | 80 | + intval($product->is_new), |
81 | + intval($product->is_top), | ||
82 | + $product->video, | ||
84 | implode (',', $fotos), | 83 | implode (',', $fotos), |
85 | ]; | 84 | ]; |
86 | 85 | ||
@@ -91,8 +90,7 @@ class Export extends Model { | @@ -91,8 +90,7 @@ class Export extends Model { | ||
91 | 90 | ||
92 | 91 | ||
93 | fputcsv($handle, $to_write, ';'); | 92 | fputcsv($handle, $to_write, ';'); |
94 | - die('here'); | ||
95 | - unset($products[$i]); | 93 | + unset($product); |
96 | } | 94 | } |
97 | 95 | ||
98 | 96 | ||
@@ -107,7 +105,6 @@ class Export extends Model { | @@ -107,7 +105,6 @@ class Export extends Model { | ||
107 | $fittersArray = []; | 105 | $fittersArray = []; |
108 | foreach($filters as $filter){ | 106 | foreach($filters as $filter){ |
109 | $fittersArray[$filter->taxGroup->alias][] = $filter->name; | 107 | $fittersArray[$filter->taxGroup->alias][] = $filter->name; |
110 | - | ||
111 | } | 108 | } |
112 | $filterString=[]; | 109 | $filterString=[]; |
113 | 110 | ||
@@ -116,7 +113,6 @@ class Export extends Model { | @@ -116,7 +113,6 @@ class Export extends Model { | ||
116 | $filterString[] = "[{$filterName}:{$row}]"; | 113 | $filterString[] = "[{$filterName}:{$row}]"; |
117 | 114 | ||
118 | } | 115 | } |
119 | - | ||
120 | return implode('*',$filterString); | 116 | return implode('*',$filterString); |
121 | } | 117 | } |
122 | } | 118 | } |
123 | \ No newline at end of file | 119 | \ No newline at end of file |