File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
app/code/Magento/Ui/Model/Export Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -81,19 +81,30 @@ public function getCsvFile()
81
81
$ searchCriteria = $ dataProvider ->getSearchCriteria ()
82
82
->setCurrentPage ($ i )
83
83
->setPageSize ($ this ->pageSize );
84
- $ totalCount = (int ) $ dataProvider ->getSearchResult ()->getTotalCount ();
85
- $ totalPagesCount = (int ) ceil ($ totalCount / $ this ->pageSize );
86
- while ($ i <= $ totalPagesCount ) {
87
- // setTotalCount to prevent total count from being calculated in loop
84
+
85
+ $ totalCount = null ;
86
+ $ totalPagesCount = null ;
87
+
88
+ do {
88
89
$ searchResult = $ dataProvider ->getSearchResult ();
89
- $ searchResult ->setTotalCount ($ totalCount );
90
90
$ items = $ searchResult ->getItems ();
91
+
92
+ if ($ totalCount === null ) { // get total count only once
93
+ $ totalCount = $ searchResult ->getTotalCount ();
94
+ $ totalPagesCount = (int ) ceil ($ totalCount / $ this ->pageSize );
95
+ }
96
+
97
+ // call setTotalCount to prevent total count from being calculate in subsequent iterations of this loop
98
+ $ searchResult ->setTotalCount ($ totalCount );
99
+
91
100
foreach ($ items as $ item ) {
92
101
$ this ->metadataProvider ->convertDate ($ item , $ component ->getName ());
93
102
$ stream ->writeCsv ($ this ->metadataProvider ->getRowData ($ item , $ fields , $ options ));
94
103
}
104
+
95
105
$ searchCriteria ->setCurrentPage (++$ i );
96
- }
106
+ } while ($ i <= $ totalPagesCount );
107
+
97
108
$ stream ->unlock ();
98
109
$ stream ->close ();
99
110
You can’t perform that action at this time.
0 commit comments