Out of the box, Default Magento is come up with various functionality along with some helper text that makes that functionality easier to understand for the users. Generally, instead of spending the whole time in reading of user manual, these small things will help a user like a charm in need. As the name suggests, Helper text is designed to help the users and default Magento contains built in “attribute” class that let you to easily add comment or note beside the option for the better understanding for product users.
Code to add comment text for product attributes:
Here is Easiest way to add your own comment along with product attribute, all you need to add following code to InstallData.php file which is available at below path.
app\code\Vendor\Extension\Setup\InstallData.php
<!--?php namespace Vendorp\Extension\Setup; use Magento\Eav\Setup\EavSetupFactory; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface { private $eavSetupFactory; public function __construct(EavSetupFactory $eavSetupFactory) { $this->eavSetupFactory = $eavSetupFactory; } public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); $eavSetup->addAttribute( \Magento\Catalog\Model\Product::ENTITY, 'your_attribute_id', [ 'type' => 'text', 'label' => 'Attribute Label', 'input' => 'text', 'required' => false, 'sort_order' => 4, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'group' => 'Attribute Groupe', 'note' => 'Attribute Comment' ] ); $setup->endSetup(); } } </pre> <p>You can now customize this code & comment according to your need and it will definitely work for you.<br ?--> Hope this blog will help you to add comment text for product attributes. Try this and if you have any query then just comment below. Happy Coding!
Great blog. I searched it on Google and reached on your blog. I must say you have given a wonderful solution. It can be really helpful for the developers who want to add comments for product attributes.
Thank you
Great blog. I searched it on Google and reached on your blog. I must say you have given a wonderful solution. It can be really helpful for the developers who want to add comments for product attributes.
Thank you
Thank you for this informative read, I have shared it on Twitter.
Keep sharing, Thank you so much 🙂
Thank you for this informative read, I have shared it on Twitter.
Keep sharing, Thank you so much 🙂
Thank you for sharing this useful article. I was finding the solutions for adding comment text for product attributes so at last by reading this great article I found the perfect solution. Keep posting such useful articles.
Thank you so much,
Thanks for your kind words.
Keep appreciate us for the same.
Thank you for sharing this useful article. I was finding the solutions for adding comment text for product attributes so at last by reading this great article I found the perfect solution. Keep posting such useful articles.
Thank you so much,
Thanks for your kind words.
Keep appreciate us for the same.
Much appreciated, a big help, keep posting these types of knowledgeable posts 🙂
Default Magento comes with various functionality along with some helper text which makes that functionality easier to understand for the users.
As the name suggests, Helper text is designed to help the users and default Magento contains builtin “attribute” class that let you add comment or note easily beside the option for the better understanding to product users.
Nice Post, I really found a useful post that contains useful information.