Before saying this post is a duplicate please read.

I have a real head scratcher for you. I am trying to get the current package name being used. In a clean install with 1.9, the current package name is rwd. However, all methods that I have tried return the value default. I find this very odd and wonder if anyone else has faced this problem?

I have tried the following: (please note that I have looked through as many exchange posts that I could find relating to getting this info with no luck. https://stackoverflow.com/questions/11155570/how-to-get-current-theme-name-in-magento



Mage::getStoreConfig('design/package/name', $storeId);

All of these methods return default which is not correct. I noticed that during a fresh 1.9 install the default package name is rwd. However, design/package/name does not exist in core_config_data table unless you save the configurations in the backend.

So, why does Magento return default even if the path does not yet exist in the table? Also, when it does exist and contains rwd as the package name, why does it still return default ??

Update: I should mention that I am trying to retrieve this info from the backend. It appears it will pull the right info if you are trying to retrieve it from the frontend only.



I put this:

<? var_dump(Mage::getSingleton('core/design_package')->getPackageName()); ?>

At the bottom of the footer.phtml file in magento/app/design/frontend/rwd/default/template/page/html (before even running the installer) on a fresh unpack of 1.9.

As soon as I loaded the frontend up I found string 'rwd' (length=3) in my site's footer.

I believe what package you have returned is going to depend on where exactly you put the package call. Also the following:

<? var_dump(Mage::getSingleton('core/design_package')->getTheme('frontend')); ?>

should in-fact return "default" on a vanilla 1.9 install as you're using magento/app/design/frontend/rwd/default as your theme.

For more info or to dive into how core/design_package is structured simply add the following to a template file:

<? var_dump(Mage::getSingleton('core/design_package')); ?>

The response you get should start out with something like:

  protected '_store' => null
  protected '_area' => string 'frontend' (length=8)
  protected '_name' => string 'rwd' (length=3)
  protected '_theme' => 
    array (size=5)
      'locale' => string 'default' (length=7)
      'default' => null
      'layout' => string 'default' (length=7)
      'template' => string 'default' (length=7)
      'skin' => string 'default' (length=7)

For a little more insight into how exactly design/package fallback works in 1.9 take a gander at the files in magento/app/code/core/Mage/Core/Model/Design

Hope this helps!

  • Thanks 4 this in depth response! That may be the problem as you mentioned. I am actually needing to retrieve the package name rwd in the backend. Any thoughts on how to achieve that?
    – Joe78
    Aug 9 '14 at 2:27
  • 1
    Ah, in that case your problems makes ample sense. In 1.9 adminhtml design files still live in magento/app/design/adminhtml/default/default and you're likely getting the default admin theme with any of the above methods. What exactly are you trying to achieve by showing this backend (it should already be shown in admin @ System > Configuration > General > Design > Package) Aug 9 '14 at 2:48
  • True, I am writing an extension that will need to create a folder in the correct place in their frontend skin location. For example, if someone uploads an image in my extension, I need to determine their exact theme location, and store scope in order to create the folder in the right location. Example, if there skin file is located in rwd/mytheme/ I will want to create my folder in this location. So ultimately, I need to determine their frontend package name and theme location. If it could only be simpler lol
    – Joe78
    Aug 9 '14 at 5:48
  • if you are working with an extension, you should place your design,css and js in the last fallbacking location. Means templates base/default. css, js in base/default etc. This makes sure your extension will work as desire, whatever may be the theme used by various users. Its not a strict rule. But that would be the best shot that you can do :) Aug 9 '14 at 6:42
  • Thanks @programmer_rkt I am thinking that will be the best route also. Maybe in the default/default location. Thanks!
    – Joe78
    Aug 10 '14 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.