Getting page error 404 while calling Mage::getStoreConfig with current storeId
-
22-01-2021 - |
Question
Using Magento 1.9.3 Mage::getStoreConfig
is redirecting magento admin to 404 page instead of retrieving the store field value.
In controller
$store = $this->getRequest()->getParam('website');
if (!$store) {
$storeID = 1; //use default store if none was given
} else {
$storeID = Mage::app()->getWebsite($store)->getId();
}
Mage::helper('setstartordernumber')->getOrderNumber($storeID)
In helper
class Aschroder_SetStartOrderNumber_Helper_Data extends Mage_Core_Helper_Abstract {
public function getOrderNumber($iStoreId=null) {
return Mage::getStoreConfig('sales/setstartordernumber/order',$iStoreId);
}
}
What could the code be missing? Any idea?
Update:
This issue arise only when calling Mage::getStoreConfig
from Helper.
Solution
Since Mage::getStoreConfig
causing magento return 404 with no error logs or exceptions I decided to create a custom function to get store configuration base on path and scope Id (store id in my case).
class Aschroder_SetStartOrderNumber_Helper_Data extends Mage_Core_Helper_Abstract {
// some code
public function getStoreConfig($path, $scopeId) {
$configs = Mage::getModel('core/config_data')->getCollection();
$configs->getSelect()->where('path=?', $path);
$configs->getSelect()->where('scope_id=?', $scopeId);
foreach ($configs as $val) {
return $val->getValue();
}
}
}
OTHER TIPS
Use the Below Code
$store = Mage::app()->getStore(); // store info
$configValue = Mage::getStoreConfig('sectionName/groupName/fieldName', $store);
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange