How to Add Dynamically Generated Comment for a Backend Configuration Field in Magento 2

How to Add Dynamically Generated Comment for a Backend Configuration Field in Magento 2 4

As a Magento 2 developer, you may need to add comments in the backend configuration of extensions for the ease of admin or store owner. The extension holder might not be an expert in Magento 2 and hence such comments can guide them through the extension configuration and use.

However, in particular cases, the comments can have links to the store’s URLs to show the output or redirect the admin to check the functionality implemented in the backend.

But, these links’ paths differ from one Magento 2 store to another. The extension that you are going to develop is not necessarily going to be used for a single store only. Hence you need to add dynamically generated comment for a backend configuration field in Magento 2.

The post shows how to do so programmatically.

Method to Add Dynamically Generated Comment for a Backend Configuration Field in Magento 2:

  1. Create system.xml at app\code\Vendor\Extension\etc\adminhtml

    Ā 
  2. Create DynamicComment.php at app\code\Vendor\Extension\Block\Adminhtml\System folder

That’s it.

I’ve implemented the above method as shown here:

How to Add Dynamically Generated Comment for a Backend Configuration Field in Magento 2 5

 

Now you can fill your backend configuration with dynamic comments šŸ˜„

Feel free to post your doubts in the Comments section below and I’d be happy to help.

Iā€™d be very grateful if you helped share this helpful post on social media to fellow developers!

Thanks!

 

5
(based on 14 Reviews)

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

1 comments On How to Add Dynamically Generated Comment for a Backend Configuration Field in Magento 2

Leave a reply:

Your email address will not be published.