Skip to content

Commit

Permalink
GETWO-1556] Export: Unable to Filter Data by Attribute With Input Typ…
Browse files Browse the repository at this point in the history
…e Multiple Select

     - reduced complexity of getAttributeFilterType method
  • Loading branch information
php4umagento authored and dmanners committed Feb 26, 2018
1 parent d8c59be commit 6f88d3f
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions app/code/Magento/ImportExport/Model/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Export extends \Magento\ImportExport\Model\AbstractModel
*/
const FILTER_TYPE_SELECT = 'select';

const FILTER_TYPE_MULTISELECT ='multiselect';
const FILTER_TYPE_MULTISELECT = 'multiselect';

const FILTER_TYPE_INPUT = 'input';

Expand Down Expand Up @@ -67,6 +67,17 @@ class Export extends \Magento\ImportExport\Model\AbstractModel
*/
protected $_exportAdapterFac;

/**
* @var array
*/
public static $backendTypeToFilterMapper = [
'datetime' => self::FILTER_TYPE_DATE,
'decimal' => self::FILTER_TYPE_NUMBER,
'int' => self::FILTER_TYPE_NUMBER,
'varchar' => self::FILTER_TYPE_INPUT,
'text' => self::FILTER_TYPE_INPUT
];

/**
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Filesystem $filesystem
Expand All @@ -82,7 +93,8 @@ public function __construct(
\Magento\ImportExport\Model\Export\Entity\Factory $entityFactory,
\Magento\ImportExport\Model\Export\Adapter\Factory $exportAdapterFac,
array $data = []
) {
)
{
$this->_exportConfig = $exportConfig;
$this->_entityFactory = $entityFactory;
$this->_exportAdapterFac = $exportAdapterFac;
Expand Down Expand Up @@ -219,19 +231,19 @@ public static function getAttributeFilterType(\Magento\Eav\Model\Entity\Attribut
if ($attribute->usesSource() || $attribute->getFilterOptions()) {
return 'multiselect' == $attribute->getFrontendInput() ?
self::FILTER_TYPE_MULTISELECT : self::FILTER_TYPE_SELECT;
} elseif ('datetime' == $attribute->getBackendType()) {
return self::FILTER_TYPE_DATE;
} elseif ('decimal' == $attribute->getBackendType() || 'int' == $attribute->getBackendType()) {
return self::FILTER_TYPE_NUMBER;
} elseif ('varchar' == $attribute->getBackendType() || 'text' == $attribute->getBackendType()) {
return self::FILTER_TYPE_INPUT;
} elseif ($attribute->isStatic()) {
}

if (isset(self::$backendTypeToFilterMapper[$attribute->getBackendType()])) {
return self::$backendTypeToFilterMapper[$attribute->getBackendType()];
}

if ($attribute->isStatic()) {
return self::getStaticAttributeFilterType($attribute);
} else {
throw new \Magento\Framework\Exception\LocalizedException(
__('We can\'t determine the attribute filter type.')
);
}

throw new \Magento\Framework\Exception\LocalizedException(
__('We can\'t determine the attribute filter type.')
);
}

/**
Expand Down

0 comments on commit 6f88d3f

Please sign in to comment.