Question

I've written a module with a config section that saves it's data as a serialized array.

After having tested the module and making sure it works, I want to also include default data so that nothing needs to be set up after deploying the code to our live servers.

However, I am having a lot of trouble with setting the default data.

I've removed the stored config data from core_config_data, and have added a serialized array to the module's config.xml like this:

<template_associations><![CDATA[a:3:{s:6:"method";a:7:{i:0;s:12:"banktransfer";i:1;s:12:"banktransfer";i:2;s:12:"banktransfer";i:3;s:13:"peach_payment";i:4;s:13:"peach_payment";i:5;s:6:"rcspay";i:6;s:6:"rcspay";}s:6:"status";a:7:{i:0;s:10:"processing";i:1;s:19:"pending_eft_payment";i:2;s:10:"in_transit";i:3;s:10:"processing";i:4;s:10:"in_transit";i:5;s:10:"processing";i:6;s:10:"in_transit";}s:8:"template";a:7:{i:0;s:1:"7";i:1;s:1:"6";i:2;s:1:"8";i:3;s:1:"5";i:4;s:1:"9";i:5;s:1:"5";i:6;s:1:"9";}}]]></template_associations>

I've tested and made sure that the serialized array used for the default data is correct, and I know the path in the config.xml is correct because I have other default data that is taking effect, but the serialized array is not taking effect at all. I've also made sure that my configuration data cache is disabled.

Is there anywhere else I need to update to make sure that my instance of Magento reverts to loading the default data for this section? Should I change something about the default data itself? (I've tested with CDATA tags and without, with no success).

Was it helpful?

Solution

I had the same problem and was confused. It was working once fine in CE 1.5.x but it seems to be broken in CE 1.8/1.9

The problem is that the serialized default config is given as Mage_Core_Model_Config_Element object into Mage_Core_Helper_UnserializeArray::unserialize

This causes an exception:

exception 'Exception' with message 'Error during unserialization' in ../lib/Unserialize/Parser.php:60

This is a bug introduced by Magento 1.9.3.0 or SUPEE-8788

See here for possible solutions:

https://magento.stackexchange.com/a/146981/15114

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top