While creating custom attribute in magento 2, what is the use of below

'backend' => '', 'frontend' => '' 'class' => '' 'source' => ''

                    'type' => 'text',
                    'backend' => '',// What is the use of this
                    'frontend' => '',//What is the use of this
                    'label' => 'Sample Atrribute',
                    'input' => 'text',
                    'class' => '',// What is the use of this
                    'source' => '',// What is the use of this
                    'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                    'visible' => true,
                    'required' => true,
                    'user_defined' => false,
                    'default' => '',
                    'searchable' => false,
                    'filterable' => false,
                    'comparable' => false,
                    'visible_on_front' => false,
                    'used_in_product_listing' => true,
                    'unique' => false,
                    'apply_to' => ''

1 Answer 1


use of source, frontend and backend are given below

source/frontend/backend: Special classes associated with the attribute:

source model: provides a list of options.

frontend: defines how it should be rendered on the frontend

backend: allows you to perform certain actions when an attribute is loaded or saved.

you can get more details from this Magento DevDocs https://devdocs.magento.com/videos/fundamentals/add-new-product-attribute/

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.