2

In a custom modul that creates cronjobs I create a block like this

Mage::app('default')->loadArea('frontend');
    $layout = Mage::getSingleton('core/layout');
    $layout->getUpdate()->load('default');

    $block = $layout->createBlock('catalog/product_view_type_configurable');

and run $block->getJsonConfig();

In there, another block is created

$this->getLayout()->createBlock('catalog/product_view_attributes');

and its template set

$childBlock->setTemplate('catalog/product/view/attributes.phtml')

But I get the error:

Not valid template file:adminhtml/base/default/template/catalog/product/view/attributes.phtml

the file is in my frontend/template1/template2/catalog/product/view/attributes.phtml

How can I fix this? Obviously, I just don't want to copy the file to that directory.

1

this does the trick

Mage::app()->getLocale()->emulate($store);
        Mage::app()->setCurrentStore(Mage::app()->getStore($store));

        Mage::getDesign()->setArea('frontend')
            ->setStore($store)
            ->setPackageName('template') //Name of Package
            ->setTheme('template');

        Mage::getSingleton('core/design')
            ->loadChange(1);

        $layout = Mage::getSingleton('core/layout');

        $block = $layout->createBlock('catalog/product_view_type_configurable');

credit goes here: How to get frontend area layout in admin side?

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.