public function getFieldType(AttributeInterface $attribute)
    {
        $type = FieldInterface::FIELD_TYPE_TEXT;

        if ($attribute->getSourceModel() == 'Magento\Eav\Model\Entity\Attribute\Source\Boolean') {
            $type = FieldInterface::FIELD_TYPE_BOOLEAN;
        } elseif ($attribute->getBackendType() == 'int') {
            $type = FieldInterface::FIELD_TYPE_INTEGER;
        } elseif ($attribute->getFrontendClass() == 'validate-digits') {
            $type = FieldInterface::FIELD_TYPE_LONG;
        } 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()) {
            $type = $attribute->getSourceModel() ? FieldInterface::FIELD_TYPE_KEYWORD : FieldInterface::FIELD_TYPE_INTEGER ;
        }

        return $type;
    }
public function getFieldType(AttributeInterface $attribute)
    {
        $type = FieldInterface::FIELD_TYPE_TEXT;

        if ($attribute->getSourceModel() == 'Magento\Eav\Model\Entity\Attribute\Source\Boolean') {
            $type = FieldInterface::FIELD_TYPE_BOOLEAN;
        } elseif ($attribute->getBackendType() == 'int') {
            $type = FieldInterface::FIELD_TYPE_INTEGER;
        } elseif ($attribute->getFrontendClass() == 'validate-digits') {
            $type = FieldInterface::FIELD_TYPE_LONG;
        } 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()) {
            $type = $attribute->getSourceModel() ? FieldInterface::FIELD_TYPE_KEYWORD : FieldInterface::FIELD_TYPE_INTEGER ;
        }

        return $type;
    }
public function getFieldType ( AttributeInterface $ attribute ) { $ type = FieldInterface :: FIELD_TYPE_TEXT ; if ( $ attribute -> getSourceModel ( ) == 'Magento\Eav\Model\Entity\Attribute\Source\Boolean' ) { $ type = FieldInterface :: FIELD_TYPE_BOOLEAN ; } elseif ( $ attribute -> getBackendType ( ) == 'int' ) { $ type = FieldInterface :: FIELD_TYPE_INTEGER ; } elseif ( $ attribute -> getFrontendClass ( ) == 'validate-digits' ) { $ type = FieldInterface :: FIELD_TYPE_LONG ; } 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 ( ) ) { $ type = $ attribute -> getSourceModel ( ) ? FieldInterface :: FIELD_TYPE_KEYWORD : FieldInterface :: FIELD_TYPE_INTEGER ; } return $ type ; }
Get mapping field type for an attribute.

@param AttributeInterface $attribute Product attribute.

@return string
Get mapping field type for an attribute .