How to create custom variable programatically for template in magento 2 The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)send 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

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

Why can't devices on different VLANs, but on the same subnet, communicate?

What information about me do stores get via my credit card?

Circular reasoning in L'Hopital's rule

How to determine omitted units in a publication

Variable with quotation marks "$()"

Didn't get enough time to take a Coding Test - what to do now?

Can a flute soloist sit?

Student Loan from years ago pops up and is taking my salary

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

60's-70's movie: home appliances revolting against the owners

Can withdrawing asylum be illegal?

Loose spokes after only a few rides

"... to apply for a visa" or "... and applied for a visa"?

What is the role of 'For' here?

Can the DM override racial traits?

Is there a way to generate uniformly distributed points on a sphere from a fixed amount of random real numbers per point?

1960s short story making fun of James Bond-style spy fiction

What was the last x86 CPU that did not have the x87 floating-point unit built in?

Homework question about an engine pulling a train

How to handle characters who are more educated than the author?

What is the padding with red substance inside of steak packaging?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

Word for: a synonym with a positive connotation?



How to create custom variable programatically for template in magento 2



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)send 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 Apr 9 at 10:00







      Stack user

















      asked Apr 9 at 9:30









      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
            Apr 9 at 10:01











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

            – Pritam Info 24
            Apr 9 at 10:16


















          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
              Apr 9 at 10:01











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

              – Pritam Info 24
              Apr 9 at 10:16















            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
              Apr 9 at 10:01











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

              – Pritam Info 24
              Apr 9 at 10:16













            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 Apr 9 at 9:45









            Pritam Info 24Pritam Info 24

            79217




            79217












            • but I need to achieve this programatically

              – Stack user
              Apr 9 at 10:01











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

              – Pritam Info 24
              Apr 9 at 10:16

















            • but I need to achieve this programatically

              – Stack user
              Apr 9 at 10:01











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

              – Pritam Info 24
              Apr 9 at 10:16
















            but I need to achieve this programatically

            – Stack user
            Apr 9 at 10:01





            but I need to achieve this programatically

            – Stack user
            Apr 9 at 10:01













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

            – Pritam Info 24
            Apr 9 at 10:16





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

            – Pritam Info 24
            Apr 9 at 10:16













            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 Apr 9 at 10:16









                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

                    Sum ergo cogito? 1 nng

                    419 nièngy_Soadمي 19bal1.5o_g

                    Queiggey Chernihivv 9NnOo i Zw X QqKk LpB