Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 6f88d3f

Browse files
php4umagentodmanners
authored andcommitted
GETWO-1556] Export: Unable to Filter Data by Attribute With Input Type Multiple Select
- reduced complexity of getAttributeFilterType method
1 parent d8c59be commit 6f88d3f

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

app/code/Magento/ImportExport/Model/Export.php

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Export extends \Magento\ImportExport\Model\AbstractModel
3030
*/
3131
const FILTER_TYPE_SELECT = 'select';
3232

33-
const FILTER_TYPE_MULTISELECT ='multiselect';
33+
const FILTER_TYPE_MULTISELECT = 'multiselect';
3434

3535
const FILTER_TYPE_INPUT = 'input';
3636

@@ -67,6 +67,17 @@ class Export extends \Magento\ImportExport\Model\AbstractModel
6767
*/
6868
protected $_exportAdapterFac;
6969

70+
/**
71+
* @var array
72+
*/
73+
public static $backendTypeToFilterMapper = [
74+
'datetime' => self::FILTER_TYPE_DATE,
75+
'decimal' => self::FILTER_TYPE_NUMBER,
76+
'int' => self::FILTER_TYPE_NUMBER,
77+
'varchar' => self::FILTER_TYPE_INPUT,
78+
'text' => self::FILTER_TYPE_INPUT
79+
];
80+
7081
/**
7182
* @param \Psr\Log\LoggerInterface $logger
7283
* @param \Magento\Framework\Filesystem $filesystem
@@ -82,7 +93,8 @@ public function __construct(
8293
\Magento\ImportExport\Model\Export\Entity\Factory $entityFactory,
8394
\Magento\ImportExport\Model\Export\Adapter\Factory $exportAdapterFac,
8495
array $data = []
85-
) {
96+
)
97+
{
8698
$this->_exportConfig = $exportConfig;
8799
$this->_entityFactory = $entityFactory;
88100
$this->_exportAdapterFac = $exportAdapterFac;
@@ -219,19 +231,19 @@ public static function getAttributeFilterType(\Magento\Eav\Model\Entity\Attribut
219231
if ($attribute->usesSource() || $attribute->getFilterOptions()) {
220232
return 'multiselect' == $attribute->getFrontendInput() ?
221233
self::FILTER_TYPE_MULTISELECT : self::FILTER_TYPE_SELECT;
222-
} elseif ('datetime' == $attribute->getBackendType()) {
223-
return self::FILTER_TYPE_DATE;
224-
} elseif ('decimal' == $attribute->getBackendType() || 'int' == $attribute->getBackendType()) {
225-
return self::FILTER_TYPE_NUMBER;
226-
} elseif ('varchar' == $attribute->getBackendType() || 'text' == $attribute->getBackendType()) {
227-
return self::FILTER_TYPE_INPUT;
228-
} elseif ($attribute->isStatic()) {
234+
}
235+
236+
if (isset(self::$backendTypeToFilterMapper[$attribute->getBackendType()])) {
237+
return self::$backendTypeToFilterMapper[$attribute->getBackendType()];
238+
}
239+
240+
if ($attribute->isStatic()) {
229241
return self::getStaticAttributeFilterType($attribute);
230-
} else {
231-
throw new \Magento\Framework\Exception\LocalizedException(
232-
__('We can\'t determine the attribute filter type.')
233-
);
234242
}
243+
244+
throw new \Magento\Framework\Exception\LocalizedException(
245+
__('We can\'t determine the attribute filter type.')
246+
);
235247
}
236248

237249
/**

0 commit comments

Comments
 (0)