Commit d49a27c95126a0115a22cd79a275fd0496185f49
1 parent
7253a9a0
Export fix
Showing
1 changed file
with
7 additions
and
5 deletions
Show diff stats
common/modules/product/models/Export.php
@@ -17,6 +17,8 @@ | @@ -17,6 +17,8 @@ | ||
17 | 17 | ||
18 | public function process($filename = NULL, $from = 0) | 18 | public function process($filename = NULL, $from = 0) |
19 | { | 19 | { |
20 | + | ||
21 | + $limit = 100; | ||
20 | if(empty( $filename )) { | 22 | if(empty( $filename )) { |
21 | $filename = 'products_' . date('d_m_Y_H_i') . '.csv'; | 23 | $filename = 'products_' . date('d_m_Y_H_i') . '.csv'; |
22 | $handle = fopen(\Yii::getAlias('@storage/sync/') . $filename, "w"); | 24 | $handle = fopen(\Yii::getAlias('@storage/sync/') . $filename, "w"); |
@@ -26,13 +28,13 @@ | @@ -26,13 +28,13 @@ | ||
26 | 28 | ||
27 | 29 | ||
28 | $products = Product::find() | 30 | $products = Product::find() |
29 | - ->joinWith([ | 31 | + ->with( |
30 | 'variantsWithFilters', | 32 | 'variantsWithFilters', |
31 | 'brand', | 33 | 'brand', |
32 | - 'categories', | ||
33 | - ]) | 34 | + 'categories' |
35 | + ) | ||
34 | ->with('filters') | 36 | ->with('filters') |
35 | - ->limit(1000) | 37 | + ->limit($limit) |
36 | ->offset($from) | 38 | ->offset($from) |
37 | ->all(); | 39 | ->all(); |
38 | $filesize = Product::find() | 40 | $filesize = Product::find() |
@@ -79,7 +81,7 @@ | @@ -79,7 +81,7 @@ | ||
79 | 81 | ||
80 | fclose($handle); | 82 | fclose($handle); |
81 | 83 | ||
82 | - $from += 1000; | 84 | + $from += $limit; |
83 | $end = false; | 85 | $end = false; |
84 | if($from > $filesize) { | 86 | if($from > $filesize) { |
85 | $end = true; | 87 | $end = true; |