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
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
add a comment |
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
add a comment |
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
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
magento2 backend plugin
edited 5 hours ago
Ronak Rathod
869112
869112
asked 15 hours ago
Matias DelgadoMatias Delgado
104
104
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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')
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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')
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
add a comment |
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')
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
add a comment |
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')
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')
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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