File tree Expand file tree Collapse file tree 3 files changed +5
-36
lines changed
AdvancedPricingImportExport/Controller/Adminhtml/Export
CatalogImportExport/Model/Export
ImportExport/Model/Export/Entity Expand file tree Collapse file tree 3 files changed +5
-36
lines changed Original file line number Diff line number Diff line change @@ -34,29 +34,9 @@ public function execute()
34
34
/** @var $export \Magento\ImportExport\Model\Export */
35
35
$ export = $ this ->_objectManager ->create (\Magento \ImportExport \Model \Export::class);
36
36
$ export ->setData ($ data );
37
- $ filter = (isset ($ data ['filter ' ]) && $ data ['filter ' ]) ? $ data ['filter ' ] : null ;
38
- $ collection = $ export ->getEntityAttributeCollection ();
39
- if (!is_null ($ filter )) {
40
- $ filters = array_reduce (
41
- explode ('& ' , base64_decode ($ filter )),
42
- function ($ filter , $ item ) {
43
- list ($ key , $ value ) = explode ('= ' , $ item , 2 );
44
- $ filter [$ key ] = $ value ;
45
- return $ filter ;
46
- },
47
- []
48
- );
49
- foreach ($ filters as $ field => $ value ) {
50
- foreach ($ collection as $ attribute ) {
51
- if (stripos ($ attribute ->getData ($ field ), $ value ) === false ) {
52
- $ collection ->removeItemByKey ($ attribute ->getId ());
53
- }
54
- }
55
- }
56
- }
57
37
$ export ->filterAttributeCollection (
58
- $ attrFilterBlock ->prepareCollection ($ collection )
59
- );
38
+ $ attrFilterBlock ->prepareCollection ($ export -> getEntityAttributeCollection () )
39
+ )-> clear () ;
60
40
return $ resultLayout ;
61
41
} catch (\Exception $ e ) {
62
42
$ this ->messageManager ->addErrorMessage ($ e ->getMessage ());
Original file line number Diff line number Diff line change @@ -1548,12 +1548,8 @@ public function filterAttributeCollection(\Magento\Eav\Model\ResourceModel\Entit
1548
1548
{
1549
1549
$ validTypes = array_keys ($ this ->_productTypeModels );
1550
1550
$ validTypes = array_combine ($ validTypes , $ validTypes );
1551
-
1551
+ $ collection -> addFieldToFilter ( ' attribute_code ' , [ ' nin ' => $ this -> _bannedAttributes ]);
1552
1552
foreach (parent ::filterAttributeCollection ($ collection ) as $ attribute ) {
1553
- if (in_array ($ attribute ->getAttributeCode (), $ this ->_bannedAttributes )) {
1554
- $ collection ->removeItemByKey ($ attribute ->getId ());
1555
- continue ;
1556
- }
1557
1553
$ attrApplyTo = $ attribute ->getApplyTo ();
1558
1554
$ attrApplyTo = array_combine ($ attrApplyTo , $ attrApplyTo );
1559
1555
$ attrApplyTo = $ attrApplyTo ? array_intersect_key ($ attrApplyTo , $ validTypes ) : $ validTypes ;
@@ -1567,7 +1563,7 @@ public function filterAttributeCollection(\Magento\Eav\Model\ResourceModel\Entit
1567
1563
}
1568
1564
} else {
1569
1565
// remove attributes of not-supported product types
1570
- $ collection ->removeItemByKey ( $ attribute ->getId () );
1566
+ $ collection ->addFieldToFilter ( ' attribute_code ' ,[ ' nin ' => $ attribute ->getAttributeCode ()] );
1571
1567
}
1572
1568
}
1573
1569
return $ collection ;
Original file line number Diff line number Diff line change @@ -389,14 +389,7 @@ abstract public function export();
389
389
*/
390
390
public function filterAttributeCollection (\Magento \Eav \Model \ResourceModel \Entity \Attribute \Collection $ collection )
391
391
{
392
- $ collection ->load ();
393
-
394
- foreach ($ collection as $ attribute ) {
395
- if (in_array ($ attribute ->getAttributeCode (), $ this ->_disabledAttrs )) {
396
- $ collection ->removeItemByKey ($ attribute ->getId ());
397
- }
398
- }
399
- return $ collection ;
392
+ return $ collection ->addFieldToFilter ('attribute_code ' , ['nin ' => $ this ->_disabledAttrs ]);
400
393
}
401
394
402
395
/**
You can’t perform that action at this time.
0 commit comments