|
12 | 12 | * Export model
|
13 | 13 | *
|
14 | 14 | * @author Magento Core Team <core@magentocommerce.com>
|
| 15 | + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
15 | 16 | */
|
16 | 17 | class Export extends \Magento\ImportExport\Model\AbstractModel
|
17 | 18 | {
|
@@ -213,16 +214,44 @@ public static function getAttributeFilterType(\Magento\Eav\Model\Entity\Attribut
|
213 | 214 | return self::FILTER_TYPE_DATE;
|
214 | 215 | } elseif ('decimal' == $attribute->getBackendType() || 'int' == $attribute->getBackendType()) {
|
215 | 216 | return self::FILTER_TYPE_NUMBER;
|
216 |
| - } elseif ($attribute->isStatic() || |
217 |
| - 'varchar' == $attribute->getBackendType() || |
218 |
| - 'text' == $attribute->getBackendType() |
219 |
| - ) { |
| 217 | + } elseif ('varchar' == $attribute->getBackendType() || 'text' == $attribute->getBackendType()) { |
220 | 218 | return self::FILTER_TYPE_INPUT;
|
| 219 | + } elseif ($attribute->isStatic()) { |
| 220 | + return self::getStaticAttributeFilterType($attribute); |
221 | 221 | } else {
|
222 | 222 | throw new \Magento\Framework\Exception\LocalizedException(__('Cannot determine attribute filter type'));
|
223 | 223 | }
|
224 | 224 | }
|
225 | 225 |
|
| 226 | + /** |
| 227 | + * Determine filter type for static attribute. |
| 228 | + * |
| 229 | + * @static |
| 230 | + * @param \Magento\Eav\Model\Entity\Attribute $attribute |
| 231 | + * @return string |
| 232 | + */ |
| 233 | + public static function getStaticAttributeFilterType(\Magento\Eav\Model\Entity\Attribute $attribute) |
| 234 | + { |
| 235 | + if ($attribute->getAttributeCode() == 'category_ids') { |
| 236 | + return self::FILTER_TYPE_INPUT; |
| 237 | + } |
| 238 | + $columns = $attribute->getFlatColumns(); |
| 239 | + switch ($columns[$attribute->getAttributeCode()]['type']) { |
| 240 | + case \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER: |
| 241 | + case \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT: |
| 242 | + $type = self::FILTER_TYPE_NUMBER; |
| 243 | + break; |
| 244 | + case \Magento\Framework\DB\Ddl\Table::TYPE_DATE: |
| 245 | + case \Magento\Framework\DB\Ddl\Table::TYPE_DATETIME: |
| 246 | + case \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP: |
| 247 | + $type = self::FILTER_TYPE_DATE; |
| 248 | + break; |
| 249 | + default: |
| 250 | + $type = self::FILTER_TYPE_INPUT; |
| 251 | + } |
| 252 | + return $type; |
| 253 | + } |
| 254 | + |
226 | 255 | /**
|
227 | 256 | * MIME-type for 'Content-Type' header.
|
228 | 257 | *
|
|
0 commit comments