1

I have a module that has some input fields in admin. One of the input is an ID that will use the same value every time, so I don't want to display that input in admin anymore to avoid changing or deleting it (i'm not the only one who has access to the admin panel). I talk to a friend and he tells me to put it in a configuration xml file and take it from there. It is possible to do that? How can I create a new xml file and take that value from there? Can anyone help me please?

  • 1
    You can also answer your own question and mark it as accepted answer. So it will be useful for other users. – Jaimin Sutariya Feb 19 '18 at 8:26
  • I didn't know that. It is ok if I answer now and I delete my edit? – Ciprian Feb 19 '18 at 8:27
  • 2
    Yes it is perfectly fine. If a question has an accepted answer, it will be highlighted in question list and search results, so any user looking for an answer will know that there is an answer to the question and it is accepted as correct answer. – Jaimin Sutariya Feb 19 '18 at 8:29
1

So, after I search on the internet for a couple of days I finally managed to resolve my problem.

First I created a xml file in etc folder that looks like this:

<?xml version="1.0"?>
<config>
     <appid>app_id_here</appid>
</config>

To take the id from the file I use this code:

$configFile = Mage::getConfig()->getModuleDir('etc', 'Module_Name').DS.'file.xml';
$string = file_get_contents($configFile);
$xml = simplexml_load_string($string, 'Varien_Simplexml_Element');
echo $xml->appid;

I hope in the future this will help some people.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.