1

In Magento 2, we can add a custom attribute for a product whether programmatically or via admin (Stores->Attributes->Product)

In my case, I need to just create a custom text field to hold some custom text for products.

Should I make this field programmatically - A custom module that includes UpgradeData.php and ui_component, or should I create this custom field in Admin -> Stores -> Attributes -> product?

What's the best practice?

1

If it's just a one time endeavour for a single Magento install, I'd use the admin backend to create the custom attribute, for simplicity's sake.

However, if you want to create the same custom attribute in multiple projects or plan to work with other developers who will make use of this attribute, it's better to create the attribute programmatically in a custom module, which can then be easily distributed via composer.

|improve this answer|||||

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.