Change Magento Package, Theme and Skin programmatically on the fly

Standard

When working on Magento website, you may get requirements to change store design on fly. For example, you want to add an option on store’s frontend to change skin. When you get such requirements from your client, don’t worry because you can achieve this functionality very easily.

You can paste below code in action method for which you want to change Package/Theme/Skin

Change Package and Theme:

Mage::getDesign()->setArea('frontend') //Area (frontend|adminhtml)
        ->setPackageName('default') //Name of Package
        ->setTheme('modern'); // Name of theme

Change Package:

Mage::getDesign()->setPackageName('CUSTOM_PACKAGE_NAME');

Change Theme:

Mage::getDesign()->setTheme('CUSTOM_THEME_NAME');

Change Skin:

Mage::getDesign()->setTheme('skin', 'CUSTOM_SKIN_NAME');

Below are some useful methods to get current design configurations.

Mage::getDesign()->getPackageName();
Mage::getDesign()->getTheme('template');
Mage::getDesign()->getTheme('skin');
Mage::getDesign()->getTheme('layout');
Mage::getDesign()->getTheme('locale');
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: