解密/使用在magento中存储为config_backend_encrypted的配置值

Ovi*_*diu 21 magento

我正在研究运输模块.在system.xml我设置一些领域backend_encrypted.这是节点:

<client_id translate="label">
     <label>Client ID</label>
     <frontend_type>obscure</frontend_type>
     <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
     <sort_order>10</sort_order>
     <show_in_default>1</show_in_default>
     <show_in_website>1</show_in_website>
     <show_in_store>0</show_in_store>
</client_id>
Run Code Online (Sandbox Code Playgroud)

我需要使用cURL传递给运输API,但是,当我尝试使用$this->getConfigData('client_id');它来检索它时,它会加密出来.

我正在寻找其他模块,我看到存储的值相同但不知何故,他们设法获得正确的价值.

知道如何获得它吗?

use*_*772 31

只是用 Mage::helper('core')->decrypt($this->getConfigData('client_id'));


Ren*_*art 31

为了在$this->getConfigData('client_id');不手动解密的情况下使用,您需要通过添加来更新config.xml <client_id backend_model="adminhtml/system_config_backend_encrypted" />,请参阅下面的示例

在你的config.xml中

...
    <default>
        <carriers>
            <magepal>
                ......
                <client_id backend_model="adminhtml/system_config_backend_encrypted" />
            </magepal>
        </carriers>
    </default>
</config>
Run Code Online (Sandbox Code Playgroud)

  • 添加这将透明地解密配置值,我认为在 10 种情况下有 9 种情况是实际需要的。虽然蒂姆的解决方案有效,但我认为这是更正确的答案。 (2认同)