Hello Magento Friends,

Today I will guide you about How to Use Custom Variables in Magento 2.

Variables are a piece of information that you can use multiple times. Magento allows creating custom variables. Custom variables can be used in email templates, coding, or WYSIWYG editor.

Sometimes developers need data from only one or two fields. Instead of creating system configurations, developers can use Magento 2 Custom Variables.

So, let’s learn How to Use Custom Variables in Magento 2.

Steps to Use Custom Variables in Magento 2:

Step 1: First you need to add custom variable value from the Magento admin panel

  • On the Admin sidebar, go to System > Other Settings > Custom Variables.
  • Click Add New Variable and fill in details.

custom variable

Step 2:  Now you need to access or get custom variables value in our code so we need to add one helper file in the following path.

app\code\Vendor\Extension\Helper\Data.php

Conclusion:

Hence, this way you can Use Custom Variables in Magento 2. In case you are stuck anywhere, let me know in the comment part. Share the article and hit 5 stars. Stay updated with us for more tutorials.

Happy Coding

Click to rate this post!
[Total: 14 Average: 4.1]