I'm currently in the process of finalizing a custom controller to accept Ajax request for a quote form. I have been able to successfully set up everything, and it is sending properly. The question I have is relating to the method of linking a
Transactional e-mail template from the CMS to the controller I have set up.
I have a template in the locale of the Magento install, and have been able to load it into the Transactional email manager of the backend. How would I be able to get the id of that template and load it into the mail object? I have attempted using the simple numerical id, and that doesn't seem to be working.
Config.xml
<global>
<template>
<email>
<custom_quote>
<label>Custom Quote Form</label>
<file>custom-quote.html</file>
<type>html</type>
</custom_quote>
<trade_printer>
<label>Trade Printer Form</label>
<file>trade-printer.html</file>
<type>html</type>
</trade_printer>
</email>
</template>
</global>
this is a sample code for sending email with email template
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('custom_quote');
$emailTemplateVariables = array();
$emailTemplateVariables['myvar1'] = 'Branko';
$emailTemplateVariables['myvar2'] = 'Ajzele';
$emailTemplateVariables['myvar3'] = 'ActiveCodeline';
$processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
$emailTemplate->send('john#someemail.com','John Doe', $emailTemplateVariables,$storeId=null);
reference
After reading up on the available methods, I discovered that
loadDefault() will always load the template from the locale codebase. Utilizing loadByCode() with the name specified in the Transactional Email editor will load the customized template.
Final Code
$emailTemplate = Mage::getModel('core/email_template')->loadByCode('Template Name Here');
Related
hyee . im not so good in explanation, but i'll try.
how to get data from configuration in magento to email template. example, i'll already add new field on store information which is on:
Configuration > General > Store Information
field that i add is gst no which is the code as below.
system.xml
<fields>
<gst_no>
<label>GST No</label>
<frontend_type>text</frontend_type>
<sort_order>31</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</gst_no>
</fields>
and it function as expected. now how do i call this value on email template. example like
{{var store_email}}
on the other words, data is work as variable.
or if there is a way to set GST field as global variable like email, contact phone and etc. I already try {{config path="general/store_information/gst_no"}} but is not work.On php level it would be work like thisMage::getStoreConfig('general/store_information/gst_no');
thanks in advance :)
You are going to the right way.
Add {{config path="general/store_information/gst_no"}} in you email template.
Now Login to admin panel and navigate to System->Permissions->Variables
Click on Add new variable and fill the text box with general/store_information/gst_no. Set Is Allowed to yes
Hope this helps you!
I am working on a custom module. I want to use order item block in my custom module's custom email.
Here is my local.xml in my theme layout.
<recurring_email_order_items>
<block type="sales/order_email_items" name="items" template="recurring/items.phtml">
<action method="addItemRender"><type>default</type><block>sales/order_email_items_order_default</block><template>recurring/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>sales/order_email_items_order_grouped</block><template>recurring/default.phtml</template></action>
</block>
I have copied items.phtml, default.phtml and grouped.phtml from base to my them folder.
And below is my email template :
{{layout handle="recurring_email_order_items" order=$order}}
Email is sending out but without order data. Seems I am not passing $order object to handler.
Does anybody know, what I am doing wrong here?
I changed it a bit,
sent order id from controller to block using
$this->getLayout()->getBlock('recurring_subscribe')->setOrderId($orderId);
Get order id by using $this->getOrderId();
Load order by Mage::getModel('sales/order')->load($_orderId); in view and utilize.
I am working on custom extension.I am facing two issues.
1 ) I created a custom html page in Locale->en_Us->template->email->testEmail.hmtl.
And this is my config,.xml code :
<template> <email>
<mymodule_email_settings_client_email_template>
<label>Follow up Emails</label>
<file>test_email.html</file>
<type>html</type>
</mymodule_email_settings_client_email_template>
</email>
</template>
when i try to load it in my controller it reutrns me empty .this is my code of accessing template.
$emailTemplate = Mage::getModel('core/email_template')->loadDefault('mymodule_email_settings_client_email_template');
2) I want to load transactional and newsletter templates by there ids.I have id but don't know how can i use that templates on my custom emails.I want only the code to access the templates like above nothing more than that.Can i use that templates in my custom emails ? Thanks
please check following links use to define custom email template
http://www.excellencemagentoblog.com/magento-sending-custom-emails
http://www.atwix.com/magento/emails-for-custom-events/
hope this help you
What I want to achieve:
Clicking on a product link/image (at least in certain areas) to open a pop-up with the full product information (basically all the contents of the product view page).
What I did/tried so far:
created all the stuff outside the ajax php code (the module, links, templates, rewrites)
created the ajax controller (which can be accessed with a link similar to: http://test.com/index.php/ajaxproductview/ajax/index/id/2 ).
to follow various tutorials ( like this or this ) - that helped me get this far. But I don't want to load my custom block, I want the default product view block(s).
tried to add some code in the indexAction(). It gets there, but the code fails. I don't get any errors/notices/reports, just what it seems like an infinite loop that kills my processor.
$body = $this
->getLayout()
->createBlock('product.info') // taken from catalog.xml
->toHtml();
$this->getResponse()->setBody($body);
All the other pages work fine, and it's a fresh magento with only magneto and my module installed and activated.
My AJAX function simply gets this HTML response, puts it into a div, and opens a pop-up.
My question(s) is(are) - how can I set the product id, so the block knows what product to load, and how can I load this block correctly. I also tried something similar to this:
Thank you.
PS: I also tried this:
$layout = $this->getLayout();
$update = $layout->getUpdate();
$update->load('catalog_product_view');
$layout->generateXml();
$layout->generateBlocks();
$output = $layout->getOutput(); // $output is an empty string
The Product controller uses a helper to set the active product. You should be able to do the same in your controller!
Try this before you do your layouting:
$productId = (int) $this->getRequest()->getParam('id');
Mage::helper('catalog/product')->initProduct($productId, $this);
Another thing to be aware of:
If you add a block like the product.info block. It needs additional child blocks if it calls them in its template file.
It would be easiest to use a custom layout xml file. You can then add a specific layout for your action handle (your action handle consists of your routers node in your module's etc/config.xml file under <frontend><routers>, e.g. <Yourmodule> node, make sure to lowercase it! And then with underscores add the controller name and action name, in your case index_index) like this:
<yourmodule_index_index>
<remove name="right"/>
<remove name="left"/>
<block type="catalog/product_view" name="root" output="toHtml" template="catalog/product/view.phtml">
<!-- Add all the child blocks you need -->
</block>
</yourmodule_index_index>
This makes the view.phtml the root block which renders itself using its toHtml method.
Therefore, in your controller action, all you need is my two lines above and then:
$this->loadLayout();
$this->renderLayout();
I am trying to debug external module in Magento. In that, when i logged in admin end, I have got pop up with some message and also got one notification message.Installed module generate the code for script to alert the popup message,div to display the notification. This HTML is generated and appended in DASHBOARD page which is having body class as " adminhtml-dashboard-index"
I guess there might be some way to push the generated code with dashboard page.
What are the possible ways to add external module notification or some html or generated js script with core module like DASHBOARD?
Hope you understand my question...
Thanks in advance
Here's one way to drop a block in there. Observe the adminhtml_block_html_before event:
<events>
<adminhtml_block_html_before>
<observers>
<super_adminhtml_block_html_before>
<class>super/observer</class>
<method>beforeAdminHtml</method>
</super_adminhtml_block_html_before>
</observers>
</adminhtml_block_html_before>
</events>
Then, create a new block and append it to the notifications block.
public function beforeAdminHtml($observer)
{
$block = $observer->getEvent()->getBlock();
if ($block->getNameInLayout() == 'root') {
$extendBlock = $this->_createMyNoticeBlock();
if ($extendBlock) {
$block->getChild('notifications')->append($extendBlock);
}
}
}
I used this to insert my own HTML block where the notifications usually show within the header - shows not only on the dashboard but on all the admin pages.