且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在magento2的运行时设置程序包和主题

更新时间:2023-09-18 23:28:16

如果要在magento的运行时设置程序包和主题,只需使用此代码段即可.

If you want to Set package and theme at run time in magento simply use this code snippet.

  1. 创建一个函数ex. changeTheme('主题名称');并根据您的要求运行此功能

  1. create one function ex. changeTheme('Theme-name'); and run this function with your requirement

在php启动后在您的head.phtml中添加此功能.

add this function in your head.phtml after php start.

 function changeTheme($themeName)
 {
   Mage::getDesign()->setArea('frontend') //Area (frontend|adminhtml)
                    ->setPackageName('default') //Name of Package
                    ->setTheme($themeName); // Name of theme
 }

享受:)