I have a shell script that should send an API request to a certain endpoint, using username and password in a simple HTTP auth. Everything works fine using hard-coded values, but of course we want to make those values configurable, so each time the credentials or the endpoint change, we can adjust using the Admin interface.
The relevant part of the script is the following:
$url = Mage::getStoreConfig('my_namespace/api_name/base_url');
$username = Mage::getStoreConfig('my_namespace/api_name/username');
$password = Mage::getStoreConfig('my_namespace/api_name/password');
if (!$url) {
$this->log("`my_namespace/api_name/base_url` should be set");
$this->error = true;
}
if (!$username) {
$this->log("`my_namespace/api_name/username` should be set");
$this->error = true;
}
if (!$password) {
$this->log("`my_namespace/api_name/password` should be set");
$this->error = true;
}
if ($this->error) exit(1);
All this is inside a public function run() method of a class that extends from Mage_Shell_Abstract. Trying to run this script ends up showing all the three error messages, just like the values didn't exist in DB.
But the values are present in the database:
mysql> SELECT * FROM core_config_data WHERE path LIKE '%my_namespace%';
+-----------+---------+----------+--------------------------------+-----------------------------+
| config_id | scope | scope_id | path | value |
+-----------+---------+----------+--------------------------------+-----------------------------+
| 5986 | default | 0 | my_namespace/api_name/base_url | http://the.api-endpoint.com |
| 5987 | default | 0 | my_namespace/api_name/username | Picard |
| 5988 | default | 0 | my_namespace/api_name/password | NCC-1701 |
+-----------+---------+----------+--------------------------------+-----------------------------+
Caches were clean multiple times, so it's all good from this part. I can't see what is wrong here. Any help is welcome.