We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    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.

    Here, I share the Easiest way to add your own comment along with product attribute, all you need to add the following code to InstallData.php file which is available at below path:

    appcodeVendorExtensionSetupInstallData.php

    <?php
    namespace VendorpExtensionSetup;
    use MagentoEavSetupEavSetupFactory;
    use MagentoFrameworkSetupInstallDataInterface;
    use MagentoFrameworkSetupModuleContextInterface;
    use MagentoFrameworkSetupModuleDataSetupInterface;
    
    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(
                                               	MagentoCatalogModelProduct::ENTITY,
                                               	'your_attribute_id',
                                               	[
                                                               	'type' => 'text',
                                                               	'label' => 'Attribute Label',
                                                               	'input' => 'text',
                                                               	'required' => false,
                                                               	'sort_order' => 4,
                                                               	'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
                                                               	'group' => 'Attribute Groupe',
                                                               	'note' => 'Attribute Comment'
                                               	]
                               	);
           $setup->endSetup();
    	}
    }

     

    Hope this blog will help you to add comment text for product attributes.

    Fill the below form if you need any Magento relate help/advise/consulting.

    With Only Agency that provides a 24/7 emergency support.

      Get a Free Quote