Recently,I had a task to send an custom transactional e-mail from admin panel on some event.And the email template was same as used in the frontend store. So, I was trying to make use of the same block and phtml of frontend theme to call in that email. But,i found that that,we cannot call frontend phtml files in the emails sending from admin.
There is a concept of emulation in magento which allow us to do the same.By using this method we can make use of frontend template files to call in mails sending from Admin.
This feature is available in magento 1.5 & above version.By using
Emulation model a.k.a. Mage_Core_Model_App_Emulation class , we can emulate stores in magento.
Code to be used:
$appEmulation = Mage::getSingleton('core/app_emulation');
//Start environment emulation of the specified store
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
/*
* Any code thrown here will be executed as we are currently running that store
* with applied locale, design and similar
*/
//Stop environment emulation and restore original store
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
You will need something similar also,when you want to send custom transactional e-mail for all stores at the same time as cronjob. However,
the problem is that e-mail had {{block}} inside and block template needed to respect different theme set for each store.