Change magento package and theme programatically from admin
Posted by navaneeth on Sep 26, 2014 in Magento | No comments yet

When we are dealing with magento sometimes we need to change the package and theme of the front end,From front end its easy to do as shown in stackoverflow
Mage::getDesign()->setArea('frontend') //Area (frontend|adminhtml) ->setPackageName('default') //Name of Package ->setTheme($themeName); // Name of theme
But this code doesnt works from admin section, So we need to use the functionality of the magento’s config section
ie the code snippet will be like this
$groups['theme']['fields']['template']['value'] = 'template_name'; $groups['theme']['fields']['skin']['value'] = 'skin_name'; $groups['theme']['fields']['layout']['value'] = 'layout_name'; $groups['theme']['fields']['default']['value'] = 'template_name'; Mage::getModel('adminhtml/config_data') ->setSection('design') ->setWebsite('your_website') ->setGroups($groups) ->save();
This code is helpful when we need to create an theme manager for users in admin in which it can be made similiar to the themes section as we seen on wordpress
Hope this helps to change magento package and theme programatically from admin
Leave a Reply