How to create custom variable programatically for template in magento 2 The 2019 Stack Overflow Developer Survey Results Are Insend custom mail with variable via script{{config path variable not visible in custom variablepass custom variable/parameter from email template to phtml fileHow to include a store variable in the definition of a custom variableCustom Variable Plain Value in Email templateEmail template 'custom/mail/template' is not definedHow to add template in Custom Variable HTML Value in magentoHow to Use Custom Variable in Email Template?magento 2 dynamic value not comes in custom email templateMagento 2 add customer group as Email Template variable

Output the Arecibo Message

Why do UK politicians seemingly ignore opinion polls on Brexit?

Is flight data recorder erased after every flight?

Geography at the pixel level

Can someone be penalized for an "unlawful" act if no penalty is specified?

Is there any way to tell whether the shot is going to hit you or not?

Why did Acorn's A3000 have red function keys?

The difference between dialogue marks

Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?

What is the most effective way of iterating a std::vector and why?

Why hard-Brexiteers don't insist on a hard border to prevent illegal immigration after Brexit?

Did 3000BC Egyptians use meteoric iron weapons?

Delete all lines which don't have n characters before delimiter

Pokemon Turn Based battle (Python)

How technical should a Scrum Master be to effectively remove impediments?

Are there incongruent pythagorean triangles with the same perimeter and same area?

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Which Sci-Fi work first showed weapon of galactic-scale mass destruction?

How to answer pointed "are you quitting" questioning when I don't want them to suspect

Time travel alters history but people keep saying nothing's changed

Is bread bad for ducks?

Deal with toxic manager when you can't quit

Where to refill my bottle in India?

When should I buy a clipper card after flying to OAK?



How to create custom variable programatically for template in magento 2



The 2019 Stack Overflow Developer Survey Results Are Insend custom mail with variable via script{{config path variable not visible in custom variablepass custom variable/parameter from email template to phtml fileHow to include a store variable in the definition of a custom variableCustom Variable Plain Value in Email templateEmail template 'custom/mail/template' is not definedHow to add template in Custom Variable HTML Value in magentoHow to Use Custom Variable in Email Template?magento 2 dynamic value not comes in custom email templateMagento 2 add customer group as Email Template variable



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















With the all searching so far I have found that we can add custom variable using this:



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$model = $objectManager->get('MagentoVariableModelVariable')->loadByCode('custom-variable-code');
$plain_value = $model->getPlainValue();


but I have no idea where to add this and what to do with plain value.
Please let me know how can I create custom variable which I can use in my email template globally. Thanks










share|improve this question






























    1















    With the all searching so far I have found that we can add custom variable using this:



    $objectManager = MagentoFrameworkAppObjectManager::getInstance();
    $model = $objectManager->get('MagentoVariableModelVariable')->loadByCode('custom-variable-code');
    $plain_value = $model->getPlainValue();


    but I have no idea where to add this and what to do with plain value.
    Please let me know how can I create custom variable which I can use in my email template globally. Thanks










    share|improve this question


























      1












      1








      1


      1






      With the all searching so far I have found that we can add custom variable using this:



      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $model = $objectManager->get('MagentoVariableModelVariable')->loadByCode('custom-variable-code');
      $plain_value = $model->getPlainValue();


      but I have no idea where to add this and what to do with plain value.
      Please let me know how can I create custom variable which I can use in my email template globally. Thanks










      share|improve this question
















      With the all searching so far I have found that we can add custom variable using this:



      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $model = $objectManager->get('MagentoVariableModelVariable')->loadByCode('custom-variable-code');
      $plain_value = $model->getPlainValue();


      but I have no idea where to add this and what to do with plain value.
      Please let me know how can I create custom variable which I can use in my email template globally. Thanks







      magento2 email-templates






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday







      Stack user

















      asked yesterday









      Stack userStack user

      1156




      1156




















          2 Answers
          2






          active

          oldest

          votes


















          1














          To add a custom variable, please follow below admin path.



          1) Login in to admin.



          2) go to SYSTEM -> Custom Variable (under "Other setting").



          3) Click "Add New Variable" button.



          4) Enter Variable Code,Variable Name,Variable HTML Value
          [optional], Variable Plain Value[optional]



          5) Click "Save" button.



          enter image description here






          share|improve this answer























          • but I need to achieve this programatically

            – Stack user
            yesterday











          • you can check this answer to create custom variable programmatically stackoverflow.com/questions/41760331/…

            – Pritam Info 24
            yesterday


















          0














          In your custom module use install script to create progrmatically:



          use MagentoVariableModelVariableFactory;

          class InstallData implements InstallDataInterface


          protected $varFActory;

          public function __construct(VariableFactory $varFactory)

          $this->varFActory = $varFactory;


          /**
          * @inheritdoc
          */
          public function install(
          ModuleDataSetupInterface $setup,
          ModuleContextInterface $context
          )

          $variable = $this->varFActory->create();
          $data = [
          'code' => '',
          'name' => '',
          'html_value' => '',
          'plain_value' => '',

          ];
          $variable->setData($data);
          $variable->save();








          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269342%2fhow-to-create-custom-variable-programatically-for-template-in-magento-2%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            To add a custom variable, please follow below admin path.



            1) Login in to admin.



            2) go to SYSTEM -> Custom Variable (under "Other setting").



            3) Click "Add New Variable" button.



            4) Enter Variable Code,Variable Name,Variable HTML Value
            [optional], Variable Plain Value[optional]



            5) Click "Save" button.



            enter image description here






            share|improve this answer























            • but I need to achieve this programatically

              – Stack user
              yesterday











            • you can check this answer to create custom variable programmatically stackoverflow.com/questions/41760331/…

              – Pritam Info 24
              yesterday















            1














            To add a custom variable, please follow below admin path.



            1) Login in to admin.



            2) go to SYSTEM -> Custom Variable (under "Other setting").



            3) Click "Add New Variable" button.



            4) Enter Variable Code,Variable Name,Variable HTML Value
            [optional], Variable Plain Value[optional]



            5) Click "Save" button.



            enter image description here






            share|improve this answer























            • but I need to achieve this programatically

              – Stack user
              yesterday











            • you can check this answer to create custom variable programmatically stackoverflow.com/questions/41760331/…

              – Pritam Info 24
              yesterday













            1












            1








            1







            To add a custom variable, please follow below admin path.



            1) Login in to admin.



            2) go to SYSTEM -> Custom Variable (under "Other setting").



            3) Click "Add New Variable" button.



            4) Enter Variable Code,Variable Name,Variable HTML Value
            [optional], Variable Plain Value[optional]



            5) Click "Save" button.



            enter image description here






            share|improve this answer













            To add a custom variable, please follow below admin path.



            1) Login in to admin.



            2) go to SYSTEM -> Custom Variable (under "Other setting").



            3) Click "Add New Variable" button.



            4) Enter Variable Code,Variable Name,Variable HTML Value
            [optional], Variable Plain Value[optional]



            5) Click "Save" button.



            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered yesterday









            Pritam Info 24Pritam Info 24

            78417




            78417












            • but I need to achieve this programatically

              – Stack user
              yesterday











            • you can check this answer to create custom variable programmatically stackoverflow.com/questions/41760331/…

              – Pritam Info 24
              yesterday

















            • but I need to achieve this programatically

              – Stack user
              yesterday











            • you can check this answer to create custom variable programmatically stackoverflow.com/questions/41760331/…

              – Pritam Info 24
              yesterday
















            but I need to achieve this programatically

            – Stack user
            yesterday





            but I need to achieve this programatically

            – Stack user
            yesterday













            you can check this answer to create custom variable programmatically stackoverflow.com/questions/41760331/…

            – Pritam Info 24
            yesterday





            you can check this answer to create custom variable programmatically stackoverflow.com/questions/41760331/…

            – Pritam Info 24
            yesterday













            0














            In your custom module use install script to create progrmatically:



            use MagentoVariableModelVariableFactory;

            class InstallData implements InstallDataInterface


            protected $varFActory;

            public function __construct(VariableFactory $varFactory)

            $this->varFActory = $varFactory;


            /**
            * @inheritdoc
            */
            public function install(
            ModuleDataSetupInterface $setup,
            ModuleContextInterface $context
            )

            $variable = $this->varFActory->create();
            $data = [
            'code' => '',
            'name' => '',
            'html_value' => '',
            'plain_value' => '',

            ];
            $variable->setData($data);
            $variable->save();








            share|improve this answer



























              0














              In your custom module use install script to create progrmatically:



              use MagentoVariableModelVariableFactory;

              class InstallData implements InstallDataInterface


              protected $varFActory;

              public function __construct(VariableFactory $varFactory)

              $this->varFActory = $varFactory;


              /**
              * @inheritdoc
              */
              public function install(
              ModuleDataSetupInterface $setup,
              ModuleContextInterface $context
              )

              $variable = $this->varFActory->create();
              $data = [
              'code' => '',
              'name' => '',
              'html_value' => '',
              'plain_value' => '',

              ];
              $variable->setData($data);
              $variable->save();








              share|improve this answer

























                0












                0








                0







                In your custom module use install script to create progrmatically:



                use MagentoVariableModelVariableFactory;

                class InstallData implements InstallDataInterface


                protected $varFActory;

                public function __construct(VariableFactory $varFactory)

                $this->varFActory = $varFactory;


                /**
                * @inheritdoc
                */
                public function install(
                ModuleDataSetupInterface $setup,
                ModuleContextInterface $context
                )

                $variable = $this->varFActory->create();
                $data = [
                'code' => '',
                'name' => '',
                'html_value' => '',
                'plain_value' => '',

                ];
                $variable->setData($data);
                $variable->save();








                share|improve this answer













                In your custom module use install script to create progrmatically:



                use MagentoVariableModelVariableFactory;

                class InstallData implements InstallDataInterface


                protected $varFActory;

                public function __construct(VariableFactory $varFactory)

                $this->varFActory = $varFactory;


                /**
                * @inheritdoc
                */
                public function install(
                ModuleDataSetupInterface $setup,
                ModuleContextInterface $context
                )

                $variable = $this->varFActory->create();
                $data = [
                'code' => '',
                'name' => '',
                'html_value' => '',
                'plain_value' => '',

                ];
                $variable->setData($data);
                $variable->save();









                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                Hassan Ali ShahzadHassan Ali Shahzad

                734317




                734317



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269342%2fhow-to-create-custom-variable-programatically-for-template-in-magento-2%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form