11

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' => ''
    ]
);
27

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

  • Type

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

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

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

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

Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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