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

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

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?