get custom configuration into email template (Magento) - php

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!

Related

Add subtitle to category list magento 2

For my magento2 store I want to have a subtitle right beneath the Title the product.
Right now I have it working for the "product overview" with the next code:
I added this code to: catalog_product_view.xml
<referenceBlock name="category.product.addto">
<block class="" name="category.subtitle" template="product/view/subtitle.phtml" />
</referenceBlock>
I created a new subtitle.phtml with the next code in it:
<h3><?php /* #escapeNotVerified */ echo $block->getProduct()->getResource()->getAttribute('subtitle1')->getFrontend()->getValue($block->getProduct()); ?></h3>
But i do not know how to get it working in the category list.
Is there someone who can help me with it?
UPDATE:
the attribute i created has the right settings (used in product listing is enabled)
the code i am using is:
<referenceBlock name="product-item-details"> <block class="Magento\Framework\View\Element\Template" name="category.subtitle" template="product/view/subtitle.phtml" /> </referenceBlock>
i placed this code in "catalog_product_view.xml
Im notting getting the subtitle right beneath my title in the grid view / category view.
i think there must be something wrong with the code from the reference block but i cannot figure out where the problem is .
thanks! regards Mark
How is your attribute setuped. Check the attributes settings because attributes can be hidden.
Your code should work with following:
Make sure “Visible on Product View Page on Front-end” and “Used in Product Listing” options under storefront Properties are set to Yes.
This is a quick guess because your code should work, so please check your settings of custom attribute. If it still doesn't show up can you please provide more details

Magento Transactional Email Template

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');

Magento remove store code for default store view

I've Magento multilanguage store and I need to add store code to url. In this path System > Configuration > Web > Url Option > Add Store Code to Urls I've turn ON, then I see in url as such site.com/en (default), site.com/br (brazillian).
How I can remove EN in default site.com/en and get for default store site.com without EN path??
I have made a new extension available on GitHub that allows you to hide the default store code from URLs.
More information here: https://github.com/jreinke/magento-hide-default-store-code
By Default magento will only allow you to change this config option for the whole setup, you can't change it on a by store basis.
You can possibly update magento to allow you to specify different settings for this option per website to allow you to do what you need:
app/code/core/Mage/Core/etc/system.xml
<use_store translate="label">
<label>Add Store Code to Urls</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<backend_model>adminhtml/system_config_backend_store</backend_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</use_store>
Note, you should not change this file directly, but overrie it in your own module. You can find many tutorials out there for helping to override core magento configs and files.
if you updated the scope settings:
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
this will allow you to change the "Add Store Code to Urls" for each website/store front in the admin section.
Now you can try and set "Add Store Code to Urls" = NO for the default store
and "Add Store Code to Urls" = YES for the others.
Please note I have not tested this, so I would not do this on a live store :)
I have an alternative solution that worked well too.
Copy app/code/core/Mage/Catalog/Block/Widget/Link.php to app/code/local/Mage/Catalog/Block/Widget/Link.php
Search for (line 91 in Magento 1.7.x / line 100 in Magento 1.9.x)
$this->_href = $this->_href . $symbol . "___store=" . $store->getCode();
And modify to
$this->_href = $this->_href;
Upload and save your changes and you'll now not have your widget (dynamically) inserted links getting appended with ?___store=default.
Credit: DesignHaven

Email templates in magento

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

change my account menu position in magento

I have created custom module which added link in Left navigation menu of My Account Page. Every things is handle By modules Layout.xml.
But My Module link is appeared at Last in position i.e after News letter Subscription. I want to add this after "My Order" Menu.
How can I do this. Please help me.
Thanks
Pravin
In the XML file you can set your block to come before or after another block.
In the layout XML file add the following attribute to the block:
before="name_of_block"
Or:
after="name_of_block"
So your line would look something like this:
<block type="some/type" before="some_other_block_name" template="some/path/to/template.phtml" />
If you want it to come before any other block (or after every other block) use the following:
before="-"
Or:
after="-"

Categories