I'm programmtically creating websites/users etc ...
Here's the problem: When creating a website, I can't immediatly set the config values afterwards.
Code:
<?php
/* Website information */
$website_data = array(
'name' => 'Company name',
'code' => 'website_company_1',
'sort_order' => '1',
);
/* Save website */
$website = Mage::getModel('core/website');
$website->setData($website_data);
$website->save();
/* Get website code */
$web_code = $website->getCode();
/* R-int stores */
Mage::app()->reinitStores();
/* Config data array example */
$data = array('name' => 'Company 1', 'phone' => '056 22 33 61')
/* Set config values in array */
$groups = array();
foreach($data as $key => $value){
$groups['store_information']['fields'][$key]['value'] = $value;
}
/* Save config values */
Mage::getModel('adminhtml/config_data')
->setSection('general')
->setWebsite($web_code)
->setStore(NULL)
->setGroups($groups)
->save();
/* Re-init again */
Mage::app()->reinitStores();
However, this doesn't work for some reason, but if I create a website first(with the same code), then execute this config-save function afterwards, it works fine. As if it needs a new page load first before it can set/update config values. I thought the re-init would solve this but it doesn't ...
Thoughts?