Example #1
0
 /**
  * Get mapping field type for an attribute.
  *
  * @param AttributeInterface $attribute Product attribute.
  *
  * @return string
  */
 public function getFieldType(AttributeInterface $attribute)
 {
     $type = FieldInterface::FIELD_TYPE_STRING;
     if ($attribute->getSourceModel() == 'Magento\\Eav\\Model\\Entity\\Attribute\\Source\\Boolean') {
         $type = FieldInterface::FIELD_TYPE_BOOLEAN;
     } elseif ($attribute->getBackendType() == 'int' || $attribute->getFrontendClass() == 'validate-digits') {
         $type = FieldInterface::FIELD_TYPE_INTEGER;
     } elseif ($attribute->getBackendType() == 'decimal' || $attribute->getFrontendClass() == 'validate-number') {
         $type = FieldInterface::FIELD_TYPE_DOUBLE;
     } elseif ($attribute->getBackendType() == 'datetime') {
         $type = FieldInterface::FIELD_TYPE_DATE;
     } elseif ($attribute->usesSource() && $attribute->getSourceModel() === null) {
         $type = FieldInterface::FIELD_TYPE_INTEGER;
     }
     return $type;
 }