12

When creating an install script for Magento 2 what values are available for the type and input parts of eavSetup->addAttribute()? Or where could I look to find out?

$eavSetup->addAttribute(
    \Magento\Catalog\Model\Product::ENTITY,
    'some_attr',
    [
        'type' => '',
        'backend' => '',
        'frontend' => '',
        'label' => 'Test Attribute',
        'input' => '',
        'class' => '',
        'source' => '',
        'global' => \Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_GLOBAL,
        'visible' => true,
        'required' => false,
        'user_defined' => false,
        'default' => 0,
        'searchable' => false,
        'filterable' => false,
        'comparable' => false,
        'visible_on_front' => false,
        'used_in_product_listing' => true,
        'unique' => false,
        'apply_to' => ''
    ]
);

1 Answer 1

40

You can find type and input value from the database eav_attribute table.

  • Type

    • datetime
    • decimal
    • int
    • static
    • text
    • varchar
  • Input

    • boolean
    • date
    • gallery
    • hidden
    • image
    • media_image
    • multiline
    • multiselect
    • price
    • select
    • text
    • textarea
    • weight

You can check for backend_type column value for your type case and frontend_input column for your input value for all attributes from this table.

You can check each attribute with list of different type and input. You have get more idea to check this table.

Thanks.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.