@@ -123,6 +123,13 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
123
123
*/
124
124
protected $ _attributeTypes = [];
125
125
126
+ /**
127
+ * Product collection
128
+ *
129
+ * @var \Magento\Catalog\Model\Resource\Product\CollectionFactory
130
+ */
131
+ protected $ _entityCollectionFactory ;
132
+
126
133
/**
127
134
* Product collection
128
135
*
@@ -231,7 +238,7 @@ public function __construct(
231
238
\Magento \Framework \App \Resource $ resource ,
232
239
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
233
240
\Psr \Log \LoggerInterface $ logger ,
234
- \Magento \Catalog \Model \Resource \Product \Collection $ collection ,
241
+ \Magento \Catalog \Model \Resource \Product \CollectionFactory $ collectionFactory ,
235
242
\Magento \ImportExport \Model \Export \ConfigInterface $ exportConfig ,
236
243
\Magento \Catalog \Model \Resource \ProductFactory $ productFactory ,
237
244
\Magento \Eav \Model \Resource \Entity \Attribute \Set \CollectionFactory $ attrSetColFactory ,
@@ -243,7 +250,7 @@ public function __construct(
243
250
\Magento \Catalog \Model \Product \LinkTypeProvider $ linkTypeProvider ,
244
251
\Magento \CatalogImportExport \Model \Export \RowCustomizerInterface $ rowCustomizer
245
252
) {
246
- $ this ->_entityCollection = $ collection ;
253
+ $ this ->_entityCollectionFactory = $ collectionFactory ;
247
254
$ this ->_exportConfig = $ exportConfig ;
248
255
$ this ->_logger = $ logger ;
249
256
$ this ->_productFactory = $ productFactory ;
@@ -669,12 +676,13 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows)
669
676
}
670
677
671
678
/**
672
- * Get product collection
673
- *
674
- * @return \Magento\Catalog\Model\Resource\Product\Collection
679
+ * {@inheritdoc}
675
680
*/
676
- protected function _getEntityCollection ()
681
+ protected function _getEntityCollection ($ resetCollection = false )
677
682
{
683
+ if ($ resetCollection || empty ($ this ->_entityCollection )) {
684
+ $ this ->_entityCollection = $ this ->_entityCollectionFactory ->create ();
685
+ }
678
686
return $ this ->_entityCollection ;
679
687
}
680
688
@@ -735,23 +743,23 @@ protected function paginateCollection($page, $pageSize)
735
743
/**
736
744
* Export process
737
745
*
738
- * @see https://jira.corp.x.com/browse/MAGETWO-7894
739
746
* @return string
740
747
*/
741
748
public function export ()
742
749
{
743
750
//Execution time may be very long
744
751
set_time_limit (0 );
745
752
746
- $ this ->_prepareEntityCollection ($ this ->_getEntityCollection ());
747
- $ this ->_getEntityCollection ()->setOrder ('has_options ' , 'asc ' );
748
- $ this ->_getEntityCollection ()->setStoreId (Store::DEFAULT_STORE_ID );
749
753
$ writer = $ this ->getWriter ();
750
754
$ page = 0 ;
751
755
while (true ) {
752
756
++$ page ;
757
+ $ entityCollection = $ this ->_getEntityCollection (true );
758
+ $ entityCollection ->setOrder ('has_options ' , 'asc ' );
759
+ $ entityCollection ->setStoreId (Store::DEFAULT_STORE_ID );
760
+ $ this ->_prepareEntityCollection ($ entityCollection );
753
761
$ this ->paginateCollection ($ page , $ this ->getItemsPerPage ());
754
- if ($ this -> _getEntityCollection () ->count () == 0 ) {
762
+ if ($ entityCollection ->count () == 0 ) {
755
763
break ;
756
764
}
757
765
$ exportData = $ this ->getExportData ();
@@ -761,7 +769,7 @@ public function export()
761
769
foreach ($ exportData as $ dataRow ) {
762
770
$ writer ->writeRow ($ dataRow );
763
771
}
764
- if ($ this -> _getEntityCollection ()-> getCurPage () >= $ this -> _getEntityCollection () ->getLastPageNumber ()) {
772
+ if ($ entityCollection -> getCurPage () >= $ entityCollection ->getLastPageNumber ()) {
765
773
break ;
766
774
}
767
775
}
0 commit comments