One of the things Magento 1.9 brings to the table is unlimited theme fallback via a parent/child theme mechanism. If you ever need to find the current theme’s parent programmatically, here’s what you’ll want to do.
$design = Mage::getDesign();
$config = Mage::getSingleton('core/design_config');
$area = $design->getArea();
$package = $design->getPackageName();
$theme = $design->getTheme('');
$parent = (string)$config->getNode($area . '/' . $package . '/' . $theme . '/parent');
var_dump($parent);
The core/design_config
model/singleton is a new service model that’s responsible for reading the new theme.xml
files. Then we fetch the area, design package, and current theme. Then we use this information to query the config’s XML directly. Unfortunately, there’s no clean method for grabbing this information — direct XML reading is how it’s handled in the core code as well.
#File: app/code/core/Mage/Core/Model/Design/Fallback.php
protected function _isInheritanceDefined($area, $package, $theme)
{
$path = $area . '/' . $package . '/' . $theme . '/parent';
return $this->_config->getNode($path) !== false;
}
//...
protected function _getFallbackScheme($area, $package, $theme)
{
//...
while ($parent = (string)$this->_config->getNode($area . '/' . $package . '/' . $theme . '/parent')) {
//...
}
}
Not how I would have done, but then I wasn’t doing it.