Change magento package and theme programmatically from admin

Change magento package and theme programmatically from admin

In this post we will show you Change magento package and theme programmatically from admin, hear for Change magento package and theme programmatically from admin we will give you demo and example for implement.

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

$themeName = "add-your-theme-Name";
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 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 code and post will helped you for implement change magento package and theme programmatically from admin. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org

Leave a Comment

Your email address will not be published. Required fields are marked *

9  +  1  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US