Following this tutorial I've implemented a dynamic key => value pair setting in my magento adminhtml backend module config.
So, this is my system.xml
<shipping_method_mapping translate="label">
<label>Shipping Method Mapping</label>
<comment><![CDATA[Select an active shipping method in magento and map it to the code used by Asendia.]]></comment>
<frontend_model>infiniteconnect/fieldasendia</frontend_model>
<backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
<source_model>infiniteconnect_adminhtml/system_config_source_dropdown_activeshippingmethods</source_model>
<sort_order>4</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</shipping_method_mapping>
and this is my Activeshippingmethods.php (dropdown source model):
class Intellibi_InfiniteConnect_Adminhtml_Model_System_Config_Source_Dropdown_Activeshippingmethods
{
public function toOptionArray()
{
// Init Option Array
$optionArray = array();
// Load Magento DB Connection
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
// Query Magento DB
$active_shipping_methods = $readConnection->fetchAll(
"SELECT DISTINCT `shipping_description` AS `name` FROM ". $resource->getTableName('sales_flat_order'));
// Build Option Array
foreach ($active_shipping_methods as $active_shipping_method) {
$optionArray[] = array(
'value' => md5($active_shipping_method['name']),
'label' => Mage::helper('infiniteconnect')->__($active_shipping_method['name'])
);
}
// Finished
return $optionArray;
}
}
When I test this locally on my wamp installation; it works great:
However, when I upload this to my remote DEV server running LEMP stack, the behaviour changes and the config screen breaks/does not render correctly like this:
If I modify my Activeshippingmethods.php
dropdown source model and comment out all the direct query stuff and return an empty array, then the config screen doesn't break and renders correctly - so this is why I thought there's a problem with the direct query...
I've already checked if my remote linux server has entries in sales_flat_order
table and it does (58 distinct shipping_description).
Any idea why this isn't working correctly on a linux server, but it's fine on the WAMP server for some reason? Is this some sort of issue with my module not having the correct ACL to use core_read
connection?
var/log
folder and both empty. I've also checked mynginx
andphp-fpm
logs and nothing found nothing in there related to this error my module.shipping_description
fromsales_flat_order
table.