From 3da3ae662ca23feed8e67c23efbc01230cb7cdd3 Mon Sep 17 00:00:00 2001 From: David Manners Date: Mon, 26 Feb 2018 14:48:36 +0000 Subject: [PATCH] magento-engcom/import-export-improvements#33: add multi-select attribute filter support for product export - make sure that the abstract entity class knows how to deal with multi select attributes - add finset attribute filter when type matches \Magento\ImportExport\Model\Export::FILTER_TYPE_MULTISELECT --- .../Model/Export/Entity/AbstractEntity.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php index 5cac5e46ffa..d9e3879b4be 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEntity.php @@ -277,6 +277,18 @@ protected function _prepareEntityCollection(\Magento\Eav\Model\Entity\Collection if (is_scalar($exportFilter[$attrCode]) && trim($exportFilter[$attrCode])) { $collection->addAttributeToFilter($attrCode, ['eq' => $exportFilter[$attrCode]]); } + } elseif (\Magento\ImportExport\Model\Export::FILTER_TYPE_MULTISELECT == $attrFilterType) { + if (is_array($exportFilter[$attrCode])) { + array_filter($exportFilter[$attrCode]); + if (!empty($exportFilter[$attrCode])) { + foreach ($exportFilter[$attrCode] as $val) { + $collection->addAttributeToFilter( + $attrCode, + ['finset' => $val] + ); + } + } + } } elseif (\Magento\ImportExport\Model\Export::FILTER_TYPE_INPUT == $attrFilterType) { if (is_scalar($exportFilter[$attrCode]) && trim($exportFilter[$attrCode])) { $collection->addAttributeToFilter($attrCode, ['like' => "%{$exportFilter[$attrCode]}%"]);