As per the deployment policy, I need to programatically set design exception rules in admin for the mobile theme. I noticed on core_config_data, the value looked like:

a:1:{s:18:"_1380154833505_505";a:2:{s:6:"regexp";s:111:"iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini";s:5:"value";s:6:"mobile";}}

Which makes it quite a headache to figure out how to write a setup/installation script for it. Any advice is appreciated.


The value represents this array serialized.

array (
  '_1380154833505_505' => 
  array (
    'regexp' => 'iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini',
    'value' => 'mobile',

I assume that what throws you off is this key. _1380154833505_505.
This can be about anything, but keep the consistency you should generate this key like this:

$now = microtime (true);
$parts = explode('.', $now);
$key = '_'.$parts[0].'_'.substr($parts[1], 0, 3);

When adding the values from the admin, the key is generated by javascript like this:

'_' + d.getTime() + '_' + d.getMilliseconds()

see file app/design/adminhtml/default/default/template/system/config/form/field/array.phtml.

the php code above should simulate the same thing.

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.