Magento 2, get field backend model by path The Next CEO of Stack OverflowMagento model extension experiment, return: “class does not exist”get Product not work - Magento 2Magento 2: Plugin class does not existMagento 2 get Area CodeMagento 2: Can't install or uninstall plugins in magento 2How to get the value of field in backend model of another field in magento 2 admin configuration?Get system config values in magento 2 without constructorMagento2 REST API get all customers detailsMagento 2 plugin change price of products that have a custom attribute withMagento Website Error

What is the difference between 'contrib' and 'non-free' packages repositories?

Read/write a pipe-delimited file line by line with some simple text manipulation

Shortening a title without changing its meaning

"Eavesdropping" vs "Listen in on"

Is a distribution that is normal, but highly skewed, considered Gaussian?

Free fall ellipse or parabola?

What happens if you break a law in another country outside of that country?

How to find if SQL server backup is encrypted with TDE without restoring the backup

Man transported from Alternate World into ours by a Neutrino Detector

How does a dynamic QR code work?

Can this transistor (2N2222) take 6 V on emitter-base? Am I reading the datasheet incorrectly?

Strange use of "whether ... than ..." in official text

How to show a landlord what we have in savings?

Why does sin(x) - sin(y) equal this?

What did the word "leisure" mean in late 18th Century usage?

Gödel's incompleteness theorems - what are the religious implications?

What is a typical Mizrachi Seder like?

Does int main() need a declaration on C++?

Early programmable calculators with RS-232

Can I hook these wires up to find the connection to a dead outlet?

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact

Why doesn't Shulchan Aruch include the laws of destroying fruit trees?

Is there a rule of thumb for determining the amount one should accept for a settlement offer?



Magento 2, get field backend model by path



The Next CEO of Stack OverflowMagento model extension experiment, return: “class does not exist”get Product not work - Magento 2Magento 2: Plugin class does not existMagento 2 get Area CodeMagento 2: Can't install or uninstall plugins in magento 2How to get the value of field in backend model of another field in magento 2 admin configuration?Get system config values in magento 2 without constructorMagento2 REST API get all customers detailsMagento 2 plugin change price of products that have a custom attribute withMagento Website Error










0















I'm making a plugin for the MagentoFrameworkAppConfigScopeConfigInterface file.



I need to get the config value from database.



Right now, I manage to accomplish this, but I'm having an issue with obscured fields.



I'm getting the value that comes directly from database.



If I inject the EncryptorInterface I can decrypt it, but the problem is that I need to know when is necessary to decrypt and when should I need to return the value from database.



I have at this point of the flow the path for the config option (example: carriers/usps/userid )



I was looking for a way to detect the backend model for the field using the path to load the model.



I tried something like this:



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$field = $objectManager->create('MagentoConfigModelConfigStructure')->getElement($path);


And then try this to get the backend Model:



 if ($field->hasBackendModel()) 
$backendModel = $field->getBackendModel();
//backend model is empty



Not sure how I can achieve to detect if the field has backend model MagentoConfigModelConfigBackendEncrypted



Is there some way to read the xml tree, and using the field path get the backend model, so I can know if I should use decrypt for returning the value or not?










share|improve this question




























    0















    I'm making a plugin for the MagentoFrameworkAppConfigScopeConfigInterface file.



    I need to get the config value from database.



    Right now, I manage to accomplish this, but I'm having an issue with obscured fields.



    I'm getting the value that comes directly from database.



    If I inject the EncryptorInterface I can decrypt it, but the problem is that I need to know when is necessary to decrypt and when should I need to return the value from database.



    I have at this point of the flow the path for the config option (example: carriers/usps/userid )



    I was looking for a way to detect the backend model for the field using the path to load the model.



    I tried something like this:



    $objectManager = MagentoFrameworkAppObjectManager::getInstance();
    $field = $objectManager->create('MagentoConfigModelConfigStructure')->getElement($path);


    And then try this to get the backend Model:



     if ($field->hasBackendModel()) 
    $backendModel = $field->getBackendModel();
    //backend model is empty



    Not sure how I can achieve to detect if the field has backend model MagentoConfigModelConfigBackendEncrypted



    Is there some way to read the xml tree, and using the field path get the backend model, so I can know if I should use decrypt for returning the value or not?










    share|improve this question


























      0












      0








      0








      I'm making a plugin for the MagentoFrameworkAppConfigScopeConfigInterface file.



      I need to get the config value from database.



      Right now, I manage to accomplish this, but I'm having an issue with obscured fields.



      I'm getting the value that comes directly from database.



      If I inject the EncryptorInterface I can decrypt it, but the problem is that I need to know when is necessary to decrypt and when should I need to return the value from database.



      I have at this point of the flow the path for the config option (example: carriers/usps/userid )



      I was looking for a way to detect the backend model for the field using the path to load the model.



      I tried something like this:



      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $field = $objectManager->create('MagentoConfigModelConfigStructure')->getElement($path);


      And then try this to get the backend Model:



       if ($field->hasBackendModel()) 
      $backendModel = $field->getBackendModel();
      //backend model is empty



      Not sure how I can achieve to detect if the field has backend model MagentoConfigModelConfigBackendEncrypted



      Is there some way to read the xml tree, and using the field path get the backend model, so I can know if I should use decrypt for returning the value or not?










      share|improve this question
















      I'm making a plugin for the MagentoFrameworkAppConfigScopeConfigInterface file.



      I need to get the config value from database.



      Right now, I manage to accomplish this, but I'm having an issue with obscured fields.



      I'm getting the value that comes directly from database.



      If I inject the EncryptorInterface I can decrypt it, but the problem is that I need to know when is necessary to decrypt and when should I need to return the value from database.



      I have at this point of the flow the path for the config option (example: carriers/usps/userid )



      I was looking for a way to detect the backend model for the field using the path to load the model.



      I tried something like this:



      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $field = $objectManager->create('MagentoConfigModelConfigStructure')->getElement($path);


      And then try this to get the backend Model:



       if ($field->hasBackendModel()) 
      $backendModel = $field->getBackendModel();
      //backend model is empty



      Not sure how I can achieve to detect if the field has backend model MagentoConfigModelConfigBackendEncrypted



      Is there some way to read the xml tree, and using the field path get the backend model, so I can know if I should use decrypt for returning the value or not?







      magento2 backend plugin






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 5 hours ago









      Ronak Rathod

      869112




      869112










      asked 15 hours ago









      Matias DelgadoMatias Delgado

      104




      104




















          1 Answer
          1






          active

          oldest

          votes


















          0














          You need to add backend_model in config.xml for those filed which type obscure.



          Ex:



          <field id="account" translate="label comment" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
          <label>Account ID</label>
          <backend_model>MagentoConfigModelConfigBackendEncrypted</backend_model>
          </field>


          You need to add in confix.xml like:



          <account backend_model="MagentoConfigModelConfigBackendEncrypted">TEST</account>


          For more detail check dhl module



          Now when you use the following code, Magento will return actual value not encrypted value:



          $this->scopeConfig->getValue('yoursection/yourgroup/yourfield')





          share|improve this answer























          • Hi Sohel! I know how to use an encrypted field, but what I need to solve is to get an already existing field, using the path, and see somehow if it should be decrypted or not

            – Matias Delgado
            13 hours ago











          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%2f268220%2fmagento-2-get-field-backend-model-by-path%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You need to add backend_model in config.xml for those filed which type obscure.



          Ex:



          <field id="account" translate="label comment" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
          <label>Account ID</label>
          <backend_model>MagentoConfigModelConfigBackendEncrypted</backend_model>
          </field>


          You need to add in confix.xml like:



          <account backend_model="MagentoConfigModelConfigBackendEncrypted">TEST</account>


          For more detail check dhl module



          Now when you use the following code, Magento will return actual value not encrypted value:



          $this->scopeConfig->getValue('yoursection/yourgroup/yourfield')





          share|improve this answer























          • Hi Sohel! I know how to use an encrypted field, but what I need to solve is to get an already existing field, using the path, and see somehow if it should be decrypted or not

            – Matias Delgado
            13 hours ago















          0














          You need to add backend_model in config.xml for those filed which type obscure.



          Ex:



          <field id="account" translate="label comment" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
          <label>Account ID</label>
          <backend_model>MagentoConfigModelConfigBackendEncrypted</backend_model>
          </field>


          You need to add in confix.xml like:



          <account backend_model="MagentoConfigModelConfigBackendEncrypted">TEST</account>


          For more detail check dhl module



          Now when you use the following code, Magento will return actual value not encrypted value:



          $this->scopeConfig->getValue('yoursection/yourgroup/yourfield')





          share|improve this answer























          • Hi Sohel! I know how to use an encrypted field, but what I need to solve is to get an already existing field, using the path, and see somehow if it should be decrypted or not

            – Matias Delgado
            13 hours ago













          0












          0








          0







          You need to add backend_model in config.xml for those filed which type obscure.



          Ex:



          <field id="account" translate="label comment" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
          <label>Account ID</label>
          <backend_model>MagentoConfigModelConfigBackendEncrypted</backend_model>
          </field>


          You need to add in confix.xml like:



          <account backend_model="MagentoConfigModelConfigBackendEncrypted">TEST</account>


          For more detail check dhl module



          Now when you use the following code, Magento will return actual value not encrypted value:



          $this->scopeConfig->getValue('yoursection/yourgroup/yourfield')





          share|improve this answer













          You need to add backend_model in config.xml for those filed which type obscure.



          Ex:



          <field id="account" translate="label comment" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
          <label>Account ID</label>
          <backend_model>MagentoConfigModelConfigBackendEncrypted</backend_model>
          </field>


          You need to add in confix.xml like:



          <account backend_model="MagentoConfigModelConfigBackendEncrypted">TEST</account>


          For more detail check dhl module



          Now when you use the following code, Magento will return actual value not encrypted value:



          $this->scopeConfig->getValue('yoursection/yourgroup/yourfield')






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 15 hours ago









          Sohel RanaSohel Rana

          22.9k34460




          22.9k34460












          • Hi Sohel! I know how to use an encrypted field, but what I need to solve is to get an already existing field, using the path, and see somehow if it should be decrypted or not

            – Matias Delgado
            13 hours ago

















          • Hi Sohel! I know how to use an encrypted field, but what I need to solve is to get an already existing field, using the path, and see somehow if it should be decrypted or not

            – Matias Delgado
            13 hours ago
















          Hi Sohel! I know how to use an encrypted field, but what I need to solve is to get an already existing field, using the path, and see somehow if it should be decrypted or not

          – Matias Delgado
          13 hours ago





          Hi Sohel! I know how to use an encrypted field, but what I need to solve is to get an already existing field, using the path, and see somehow if it should be decrypted or not

          – Matias Delgado
          13 hours ago

















          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%2f268220%2fmagento-2-get-field-backend-model-by-path%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