Commit d49a27c95126a0115a22cd79a275fd0496185f49

Authored by Yarik
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 17  
18 18 public function process($filename = NULL, $from = 0)
19 19 {
  20 +
  21 + $limit = 100;
20 22 if(empty( $filename )) {
21 23 $filename = 'products_' . date('d_m_Y_H_i') . '.csv';
22 24 $handle = fopen(\Yii::getAlias('@storage/sync/') . $filename, "w");
... ... @@ -26,13 +28,13 @@
26 28  
27 29  
28 30 $products = Product::find()
29   - ->joinWith([
  31 + ->with(
30 32 'variantsWithFilters',
31 33 'brand',
32   - 'categories',
33   - ])
  34 + 'categories'
  35 + )
34 36 ->with('filters')
35   - ->limit(1000)
  37 + ->limit($limit)
36 38 ->offset($from)
37 39 ->all();
38 40 $filesize = Product::find()
... ... @@ -79,7 +81,7 @@
79 81  
80 82 fclose($handle);
81 83  
82   - $from += 1000;
  84 + $from += $limit;
83 85 $end = false;
84 86 if($from > $filesize) {
85 87 $end = true;
... ...