The following code returns a regions name by its id:
|
1 2 |
$regionModel = Mage::getModel('directory/region')->load('region_id'); $region = $regionModel->getName(); |
The following code returns a regions name by its id:
|
1 2 |
$regionModel = Mage::getModel('directory/region')->load('region_id'); $region = $regionModel->getName(); |
The following 4 examples show how to get the skin, media, base and store URLs in a MAgento block or CMS page: skin: {{skin url=’images/sampleimage.jpg’}} media: {{media url=’/sampleimage.jpg’}} base: {{base url=’yourstore/mypage.html’}} store: {{store url=’mypage.html’}}
Follow these rules and your mail templates will most likely not be considered as spam: 1. Always wrap the content in … 2. Remove all empty lines 3. Remove all font size definitions, like font:11px/1.35em 4. Avoid spam words such…
This short piece of code returns the SQL query behind a Magento collection.
|
1 |
$select = $collection->getSelect()->__toString(); |
Use the ollowing code to get a routes front name:
|
1 2 |
// will display "config" $frontName = (string)Mage::getConfig()->getNode('frontend/routers/whatever/args/frontName'); |
The code will return “config”, if you add the following XML to your modules config.xml:
|
1 2 3 4 5 6 7 8 9 10 11 |
<frontend> <routers> <whatever> <use>standard</use> <args> <module>Company_Module</module> <frontName>config</frontName> </args> </whatever> </routers> </frontend> |
See the following example on how to get the long country name by its short code:
|
1 2 3 4 5 6 7 |
$address = Mage::getModel('customer/address')->load($addressId); // DE, AT ... $countryCode = $address->getCountryId(); // Deutschland, ... $country = Mage::app()->getLocale()->getCountryTranslation($countryCode); |
Use the below code to load a Magento transaction mail template by its name:
|
1 2 |
$templateId = Mage::getModel('core/email_template')->loadByCode('<name>')->getTemplateId(); $template = Mage::getModel('core/email_template')->load($templateId); |
Use the following code to get a mail templates content by its name:
|
1 2 3 |
$mailTemplate = Mage::getModel('core/email_template'); $templateByName = $mailTemplate->loadbyCode($templateName); $text = $templateByName ->getData('template_text'); |
Use the following code to get a mail templates content by its id:
|
1 2 3 |
$mailTemplate = Mage::getModel('core/email_template'); $template = $mailTemplate->load($templateId); $text = $template->getData('template_text'); |
If you want to show the Magento messages (success, error, …) in your template file, add the following code the top of your template:
|
1 |
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?> |