@@ -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,16 @@ 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
+ $ this ->_entityCollection ->setOrder ('has_options ' , 'asc ' );
686
+ $ this ->_entityCollection ->setStoreId (Store::DEFAULT_STORE_ID );
687
+
688
+ }
678
689
return $ this ->_entityCollection ;
679
690
}
680
691
@@ -735,21 +746,18 @@ protected function paginateCollection($page, $pageSize)
735
746
/**
736
747
* Export process
737
748
*
738
- * @see https://jira.corp.x.com/browse/MAGETWO-7894
739
749
* @return string
740
750
*/
741
751
public function export ()
742
752
{
743
753
//Execution time may be very long
744
754
set_time_limit (0 );
745
755
746
- $ this ->_prepareEntityCollection ($ this ->_getEntityCollection ());
747
- $ this ->_getEntityCollection ()->setOrder ('has_options ' , 'asc ' );
748
- $ this ->_getEntityCollection ()->setStoreId (Store::DEFAULT_STORE_ID );
749
756
$ writer = $ this ->getWriter ();
750
757
$ page = 0 ;
751
758
while (true ) {
752
759
++$ page ;
760
+ $ this ->_prepareEntityCollection ($ this ->_getEntityCollection (true ));
753
761
$ this ->paginateCollection ($ page , $ this ->getItemsPerPage ());
754
762
if ($ this ->_getEntityCollection ()->count () == 0 ) {
755
763
break ;
0 commit comments