Skip to content

Commit

Permalink
magento-engcom/import-export-improvements#33: add multi-select attrib…
Browse files Browse the repository at this point in the history
…ute 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
  • Loading branch information
dmanners committed Feb 26, 2018
1 parent 4f28878 commit 3da3ae6
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]}%"]);
Expand Down

0 comments on commit 3da3ae6

Please sign in to comment.