5
5
*/
6
6
namespace Magento \CatalogImportExport \Model \Export ;
7
7
8
+ use Magento \Catalog \Model \Product as ProductEntity ;
8
9
use Magento \Catalog \Model \ResourceModel \Product \Option \Collection ;
10
+ use Magento \CatalogImportExport \Model \Import \Product as ImportProduct ;
9
11
use Magento \CatalogImportExport \Model \Import \Product \CategoryProcessor ;
12
+ use Magento \Framework \App \ObjectManager ;
10
13
use Magento \ImportExport \Model \Import ;
11
- use \Magento \Store \Model \Store ;
12
- use \Magento \CatalogImportExport \Model \Import \Product as ImportProduct ;
13
- use Magento \Catalog \Model \Product as ProductEntity ;
14
+ use Magento \Store \Model \Store ;
14
15
15
16
/**
16
17
* Export entity product model
21
22
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
22
23
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
23
24
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
25
+ * @SuppressWarnings(PHPMD.ExcessiveClassLength)
26
+ * @SuppressWarnings(PHPMD.TooManyMethods)
24
27
* @since 100.0.2
25
28
*/
26
29
class Product extends \Magento \ImportExport \Model \Export \Entity \AbstractEntity
@@ -348,6 +351,10 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
348
351
* @var string
349
352
*/
350
353
private $ productEntityLinkField ;
354
+ /**
355
+ * @var ProductFilterInterface
356
+ */
357
+ private $ filter ;
351
358
352
359
/**
353
360
* Product constructor.
@@ -369,6 +376,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
369
376
* @param ProductEntity\LinkTypeProvider $linkTypeProvider
370
377
* @param RowCustomizerInterface $rowCustomizer
371
378
* @param array $dateAttrCodes
379
+ * @param ProductFilterInterface $filter
372
380
* @throws \Magento\Framework\Exception\LocalizedException
373
381
*/
374
382
public function __construct (
@@ -388,7 +396,8 @@ public function __construct(
388
396
\Magento \CatalogImportExport \Model \Export \Product \Type \Factory $ _typeFactory ,
389
397
\Magento \Catalog \Model \Product \LinkTypeProvider $ linkTypeProvider ,
390
398
\Magento \CatalogImportExport \Model \Export \RowCustomizerInterface $ rowCustomizer ,
391
- array $ dateAttrCodes = []
399
+ array $ dateAttrCodes = [],
400
+ ?ProductFilterInterface $ filter = null
392
401
) {
393
402
$ this ->_entityCollectionFactory = $ collectionFactory ;
394
403
$ this ->_exportConfig = $ exportConfig ;
@@ -404,6 +413,7 @@ public function __construct(
404
413
$ this ->_linkTypeProvider = $ linkTypeProvider ;
405
414
$ this ->rowCustomizer = $ rowCustomizer ;
406
415
$ this ->dateAttrCodes = array_merge ($ this ->dateAttrCodes , $ dateAttrCodes );
416
+ $ this ->filter = $ filter ?? ObjectManager::getInstance ()->get (ProductFilterInterface::class);
407
417
408
418
parent ::__construct ($ localeDate , $ config , $ resource , $ storeManager );
409
419
@@ -819,9 +829,11 @@ protected function getItemsPerPage()
819
829
case 'g ' :
820
830
$ memoryLimit *= 1024 ;
821
831
// fall-through intentional
832
+ // no break
822
833
case 'm ' :
823
834
$ memoryLimit *= 1024 ;
824
835
// fall-through intentional
836
+ // no break
825
837
case 'k ' :
826
838
$ memoryLimit *= 1024 ;
827
839
break ;
@@ -913,12 +925,7 @@ protected function _prepareEntityCollection(\Magento\Eav\Model\Entity\Collection
913
925
$ exportFilter = !empty ($ this ->_parameters [\Magento \ImportExport \Model \Export::FILTER_ELEMENT_GROUP ]) ?
914
926
$ this ->_parameters [\Magento \ImportExport \Model \Export::FILTER_ELEMENT_GROUP ] : [];
915
927
916
- if (isset ($ exportFilter ['category_ids ' ])
917
- && trim ($ exportFilter ['category_ids ' ])
918
- && $ collection instanceof \Magento \Catalog \Model \ResourceModel \Product \Collection
919
- ) {
920
- $ collection ->addCategoriesFilter (['in ' => explode (', ' , $ exportFilter ['category_ids ' ])]);
921
- }
928
+ $ collection = $ this ->filter ->filter ($ collection , $ exportFilter );
922
929
923
930
return parent ::_prepareEntityCollection ($ collection );
924
931
}
@@ -979,7 +986,6 @@ protected function loadCollection(): array
979
986
$ collection = $ this ->_getEntityCollection ();
980
987
foreach (array_keys ($ this ->_storeIdToCode ) as $ storeId ) {
981
988
$ collection ->setOrder ('entity_id ' , 'asc ' );
982
- $ this ->_prepareEntityCollection ($ collection );
983
989
$ collection ->setStoreId ($ storeId );
984
990
$ collection ->load ();
985
991
foreach ($ collection as $ itemId => $ item ) {
0 commit comments