This extension enables the merchants and developers to preview mail templates from the backend with real data.
- version: 1.0.0
- extension key: Hackathon_EmailPreview
- extension on GitHub
This extension enables the merchants and developers to preview mail templates from the backend with real data.
- PHP >= 5.2.0
- Mage_Adminhtml
- Magento CE >= 1.7.0.2 (only tested on this version)
- Install the extension by copying the files into your Magento root or by using a modman compatible tool (modman, Composer).
- Clear the cache, logout from the admin panel and then login again.
- Remove the extension by removing the files.
The functionality can be used in the backend section System > Transactional Emails
.
- Click on a template in the transaction email grid and navigate to the
Preview Email
tab. - Choose the
Template type
. This is necessary because an e-mail template is not fixed to a certain template type. For example you load aNew account
template and select theTemplate type
New account
. - Unfortunately, you have do use common sense to find out which data are necessary for which template at the moment. It doesn't harm if you enter more data than necessary so if you're in doubt fill in more fields.
If you introduce new variables into existing mail templates, you have to provide Magento with actual models (ie. orders, customers, ...).
You can do so by observing the hackathon_emailpreview_render_email_before
event. You will be provided with:
templateType
. Use the template type to decide if you have to modify the parameters for this type of template.templateParams
. ThisVarien_Object
contains the parameters (ie. variables like orders, customers, ...) that will be passed to the mail template renderer.
Adding a customer with real data as a template parameter looks like this:
$templateParams = $observer->getEvent()->getData('templateParams');
$requestParams = $templateParams->getRequestParams();
$customerId = $requestParams['customerId'];
$customer = Mage::getModel('customer/customer')->load($customerId);
$templateParams->setCustomer($customer);
If you have any issues with this extension, open an issue on GitHub.
Any contribution is highly appreciated. The best way to contribute code is to open a pull request on GitHub.
-
Matthias Zeis
-
Marc Päpper
-
Tobias Hille