File tree Expand file tree Collapse file tree 4 files changed +33
-13
lines changed
CatalogImportExport/Model/Export Expand file tree Collapse file tree 4 files changed +33
-13
lines changed Original file line number Diff line number Diff line change @@ -1548,10 +1548,12 @@ 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
- if (!empty ($ this ->_bannedAttributes )) {
1552
- $ collection ->addFieldToFilter ('attribute_code ' , ['nin ' => $ this ->_bannedAttributes ]);
1553
- }
1551
+
1554
1552
foreach (parent ::filterAttributeCollection ($ collection ) as $ attribute ) {
1553
+ if (in_array ($ attribute ->getAttributeCode (), $ this ->_bannedAttributes )) {
1554
+ $ collection ->removeItemByKey ($ attribute ->getId ());
1555
+ continue ;
1556
+ }
1555
1557
$ attrApplyTo = $ attribute ->getApplyTo ();
1556
1558
$ attrApplyTo = array_combine ($ attrApplyTo , $ attrApplyTo );
1557
1559
$ attrApplyTo = $ attrApplyTo ? array_intersect_key ($ attrApplyTo , $ validTypes ) : $ validTypes ;
@@ -1565,7 +1567,7 @@ public function filterAttributeCollection(\Magento\Eav\Model\ResourceModel\Entit
1565
1567
}
1566
1568
} else {
1567
1569
// remove attributes of not-supported product types
1568
- $ collection ->addFieldToFilter ( ' attribute_code ' ,[ ' nin ' => $ attribute ->getAttributeCode ()] );
1570
+ $ collection ->removeItemByKey ( $ attribute ->getId () );
1569
1571
}
1570
1572
}
1571
1573
return $ collection ;
Original file line number Diff line number Diff line change @@ -430,14 +430,25 @@ public function prepareCollection(\Magento\Framework\Data\Collection $collection
430
430
return $ this ->getCollection ();
431
431
}
432
432
433
- protected function _prepareCollection ()
433
+ /**
434
+ * @inheritDoc
435
+ *
436
+ * @param \Magento\Backend\Block\Widget\Grid\Column $column
437
+ * @return $this
438
+ */
439
+ protected function _addColumnFilterToCollection ($ column )
434
440
{
435
- if ($ this ->getCollection ()) {
436
- if ($ this ->getCollection ()->isLoaded ()) {
437
- $ this ->getCollection ()->clear ();
441
+ $ collection = $ this ->getCollection ();
442
+ $ field = $ column ->getFilterIndex () ?? $ column ->getIndex ();
443
+ $ condition = $ column ->getFilter ()->getData ('value ' );
444
+ if ($ field && isset ($ condition )) {
445
+ foreach ($ this ->getCollection () as $ attribute ) {
446
+ if (stripos ($ attribute ->getData ($ field ), $ condition ) === false ) {
447
+ $ collection ->removeItemByKey ($ attribute ->getId ());
448
+ }
438
449
}
439
450
}
440
451
441
- return parent :: _prepareCollection () ;
452
+ return $ this ;
442
453
}
443
454
}
Original file line number Diff line number Diff line change @@ -378,8 +378,11 @@ public function getAttributeCollection()
378
378
*/
379
379
public function filterAttributeCollection (\Magento \Framework \Data \Collection $ collection )
380
380
{
381
- if (!empty ($ this ->_disabledAttributes )) {
382
- $ collection ->addFieldToFilter ('attribute_code ' , ['nin ' => $ this ->_disabledAttributes ]);
381
+ /** @var $attribute \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */
382
+ foreach ($ collection as $ attribute ) {
383
+ if (in_array ($ attribute ->getAttributeCode (), $ this ->_disabledAttributes )) {
384
+ $ collection ->removeItemByKey ($ attribute ->getId ());
385
+ }
383
386
}
384
387
385
388
return $ collection ;
Original file line number Diff line number Diff line change @@ -389,8 +389,12 @@ abstract public function export();
389
389
*/
390
390
public function filterAttributeCollection (\Magento \Eav \Model \ResourceModel \Entity \Attribute \Collection $ collection )
391
391
{
392
- if (!empty ($ this ->_disabledAttrs )) {
393
- $ collection ->addFieldToFilter ('attribute_code ' , ['nin ' => $ this ->_disabledAttrs ]);
392
+ $ collection ->load ();
393
+
394
+ foreach ($ collection as $ attribute ) {
395
+ if (in_array ($ attribute ->getAttributeCode (), $ this ->_disabledAttrs )) {
396
+ $ collection ->removeItemByKey ($ attribute ->getId ());
397
+ }
394
398
}
395
399
return $ collection ;
396
400
}
You can’t perform that action at this time.
0 commit comments