Search

shamjascp

This WordPress.com site is the bee's knees

Month

July 2014

Email template edit in magento

https://www.yireo.com/tutorials/magento/magento-theming/1670-customizing-magento-email-templates

Customizing Magento email templates

Last Updated: 20 June 2014
Created: 16 March 2014

Jisse Reitsma
Written by Jisse Reitsma

Jisse is the co-founder and lead developer of Yireo – creating and maintaining the various Yireo extensions for Joomla!, Magento and MageBridge.

Customizing Magento involves many different things, but an area easily overlooked deals with the emails sent to your customers. Emailing is ofcourse a vital part of the whole experience a customer has in your shop, so making sure the look and feel of those emails matches your shop is important. Let’s see how this is done.
Overview of email templating

Emails (or often referred to as transactional emails) are – just like the entire Magento theme – based on files in the filesystem: If you open up the folder app/locale/en_US/template/email you will numerous files. Don’t edit them directly, because any Magento upgrade will override your changes. Instead, the purpose of these files is to override them.

You can override these email templates either using the Magento Admin Panel, or by copying them to your Magento theme. The first approach allows for easy editing using the Magento Admin Panel, but this interface lacks nice editing features like syntax highlighting or code completion. Ofcourse, you can copy the textarea contents ofcourse to your local editor modify things there and copy the code back into the textarea once you’re done.

An alternative is to copy the email templates to your theming folder (app/design/frontend). This does not work out of the box with Magento, but there are various third party solutions out there that allow you to override email templates this way. (We offer you one solution for free.)

Either solution is fine. It is up to you to find out which approach you like best.
Modifying email templates in the Magento Admin Panel

In the Magento Admin Panel, email templates can be managed through System > Transactional Emails. The overview of email templates is empty by default, which means that all email templates are there on the filesystem but you have not created any override in the backend yet.

You can create a new override through the button Add New Template. In the new screen, select a template from the dropdown, change the locale if you want and hit the button Load Template. All code will then be copied from the filesystem to the Magento Admin Panel, so you can modify it at your will.

Each override also has a name, which used only internally. The subject and content end up in the mail that is actually sent to the customer.
Modifying email templates in the filesystem

Email templates are stored by default in the Magento filesystem in the folder app/locale/en_US/template/email and its subfolder sales. Do not modify these files. That would classify as a core hack and is unwise for numerous reasons. Unfortunately the Magento core does not allow you to create a theme override of these files. With our free extension Yireo EmailOverride you can bypass this problem.

Install the extension through your MagentoConnect manager or by uploading the patch-files, flush the Magento cache, and you are set to go. The EmailOverride extension allows you to copy files to your own themes locale folder. Here is one example, the first line being the original file, the second line being the theme override if your theme is called YOURTHEME:

app/locale/en_US/template/email/account_new.html
app/design/frontend/default/YOURTHEME/locale/en_US/template/email/account_new.html

Another example:

app/locale/en_US/template/email/sales/invoice_new.html
app/design/frontend/default/YOURTHEME/locale/en_US/template/email/sales/invoice_new.html

The cool thing of this approach is that you can also have different templates per Store View. The Magento backend approach does not allow for this. We use this approach personally, because it allows us to copy common email changes around between Magento sites on different servers.
Inspecting the code of email templates

In either case, you will end up with the code of the default email templates, which you can then edit to fit your needs. When looking at this code, you will discover HTML-code, CSS-code and some special code between brackets {{like this}} which Magento calls CMS tags. You should be able to find your way with HTML-code and CSS-code.

The CMS tags are more difficult – it requires programming skills to understand what is done here. Basically the tags are similar to PHP-code, as in that they refer to variables. Sometimes these variables are flat strings that can printed directly. For instance, your company logo (as configured in the Magento System Configuration) is printed like this:

{{var logo_url}}

But in some other cases, more complex structures are used. For instance, in order emails, the actual order is being reffered to as a variable object $order, and the CMS-tags allow you to call upon PHP-methods of that object. Here the customers full name is fetched using the getCustomerName() method:

{{htmlescape var=$order.getCustomerName()}}

To know which objects and which object methods can be used where, you’ll have to debug which Magento class contains which functions – most likely by simply reading the Magento source code. Definitely a task for a Magento developer. Also, do not simply copy objects from one email to another. Every email has specific variables inserted into it. If you would copy the $order object to the contact email, this will result in a PHP Fatal Error, which again causes the email never to be sent.
Designing for multiple email clients

One of the harder parts of getting the design of email templates straight is that there are no standards for interpreting HTML-code in email clients: Every email client (Thunderbird, Outlook, Evolution, Postbox) uses its own HTML-rendering engine which might display your HTML code differently. The best approach to bypass these issues is to keep your emails basic and simple, and use old standards instead of new standards. For instance, HTML5 and CSS3 will only be partially supported, while HTML4 and CSS2 will work in almost all email clients. Most commonly you will add CSS properties to HTML elements using their style attribute.
Testing emails

When editing an email within the Magento Admin Panel, you can find a button Preview Template which opens up the mail in a new browser window. Unfortunately, this preview does not include actual data like invoice information or the actual products ordered. Also, this preview does not allow you to test the email under various email clients.

The usual way to test this, is to create a new order in the frontend (by adding products to the cart and completing the cart) so that an order email is being sent to a specific address. This procedure is very lengthy however. Also when you need to test the email layout under numerous email clients, you will need to create orders for each email address.

Our Yireo EmailTester extension definitely makes life easier: Within the Magento Admin Panel, you can visit the extensions control panel and use it to preview any email in your browser as you see fit. Real life data like order information and customer addresses are inserted on the fly. You can also quickly enter a specific email address to send the email to. This way you can send the same order email quickly to multiple email addresses.

Advertisements

Delete dummy orders in magento

copy and run in phpmydmin ….

SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_comment`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_comment`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_track`;
TRUNCATE `sales_invoiced_aggregated`;
TRUNCATE `sales_invoiced_aggregated_order`;
TRUNCATE `sales_payment_transaction`;
TRUNCATE `sales_order_aggregated_created`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_flat_creditmemo` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_payment_transaction` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_aggregated_created` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;

find a block in magento

Step 1: find a class and serch the class in whole file you will find a phtml page

step 2: in that a block name
eg:- getCfg(‘magento_blocks/footer_links’)): ?>
like will display in this we need to copy footer-links

step 3: and paste into static block search field you can find the corresponding block

Magento CE 1.7.0.2 how to add Mage Captcha to Contact Us form

http://www.magentocommerce.com/boards/viewthread/298363/

Quick outline how to add Magento builtin captcha mechanism to Contact Us default page.

1) To add Contact Us form to Admin/Config interface you could
a) find captcha/forms element in core_config table and add “contact_form” form name to the list
b) modify config.xml in /app/code/core/Mage/Captcha/etc
in – <frontend> – <areas> add something like

<contact_form>
<label>Contact Us</label>
</contact_form>

and in – <always_for>

<contact_form>1</contact_form>

Also there\\\’s a miss for translation in the config file, so you should add this to the <frontend> section:

<translate>
<modules>
<Mage_Captcha>
<files>
<default>Mage_Captcha.csv</default>
</files>
</Mage_Captcha>
</modules>
</translate>

Refresh cache. Login to Admin, and make sure Contact Us form is listed in CAPTCHA configuration

2) Modify captcha layout xml file in frontend/base/default (or your theme)
add this section

<contacts_index_index>
<reference name="contactForm">
<block type="core/text_list" name="form.additional.info">
<block type=\\\"captcha/captcha\\\" name=\\\"captcha\\\">
<reference name=\\\"head\\\">
<action method=\\\"addJs\\\">
<file>mage/captcha.js</file>
</action>
</reference>
<action method=\\\"setFormId\\\">
<formId>contact_form</formId>
</action>
<action method=\\\"setImgWidth\\\">
<width>230</width>
</action>
<action method=\\\"setImgHeight\\\">
<width>50</width>
</action>
</block>
</block>
</reference>
</contacts_index_index>

Refresh cache

3) Modify form code in /frontend/base/default/template/contacts/form.phtml to add placeholder to render captcha layout
Add this line of code right before </ul>

<?php echo $this->getChildHtml(\\\'form.additional.info\\\'); ?>

4) FInal part – how to\\\”trap\\\” the post from the Contact Us form and check the captcha
Mage uses Events and Observer to achieve this, and it works very well for the forms/events they have implemented this feature. I was not able to find events specific for Contact Us form, so, IMHO the most obvious solution is to override indexController in code/core/Mage/Contacts/controllers and in the postAction method, inside try block add the following code:

$formId = \\\'contact_form\\\';
$captchaModel = Mage::helper(\\\'captcha\\\')->getCaptcha($formId);
if ($captchaModel->isRequired()) {
if (!$captchaModel->isCorrect($this->_getCaptchaString($this->getRequest(), $formId))) {
Mage::getSingleton(\\\'customer/session\\\')->addError(Mage::helper(\\\'captcha\\\')->__(\\\'Incorrect CAPTCHA.\\\'));
$this->setFlag(\\\'\\\', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
Mage::getSingleton(\\\'customer/session\\\')->setCustomerFormData($this->getRequest()->getPost());
$this->getResponse()->setRedirect(Mage::getUrl(\\\'*/*/\\\'));
return;
}
}

and add this \\\”utility method to the controller class:

protected function _getCaptchaString($request, $formId)
{
$captchaParams = $request->getPost(Mage_Captcha_Helper_Data::INPUT_NAME_FIELD_VALUE);
return $captchaParams[$formId];
}

5) Refresh cache, and give it a try
To apply captcha in contact us form go to your admin panel setting system->configuration->customer configuration->Captcha Enable captcha if it disable you can see “Contact us Form” in multiselect form area select it and save configuration. see your captcha on front-end.
 

 

 

After login captcha will not come so do as follows

 

Here You can override core captcha model because captcha is not appear after customer login if you want to display captcha after customer login so you need to override Mage_Captcha_Model_Zend file _isUserAuth() function create Zend.php file in app/code/local/Compny/Captcha/Model/Zend.php

<?php

class Compny_Captcha_Model_Zend extends Mage_Captcha_Model_Zend
{

protected function _isUserAuth()
{
//die(‘function called’);
/* return Mage::app()->getStore()->isAdmin()
? Mage::getSingleton(‘admin/session’)->isLoggedIn()
: Mage::getSingleton(‘customer/session’)->isLoggedIn();*/
}

}

In this function you need to only comment function code.

bulk product upload via excel in magento

https://www.impression.co.uk/blog/946/importing-images-magento-data-profiles-csv-xml/#import

Magento Import/Export via CSV

Initially, for product imports, the standard importer works very well. You’re able to import every piece of product data that you require, so long as the spreadsheet is setup correctly and you have already done the work on the website to set up your configuration, categories and attribute sets. Magento have provided detailed instruction on this page for users looking to get started with importing products into Magento. The problem appears when it comes to uploading images. Various sources online (plus our experience!) indicate issues around images appearing exclusively on the store view, or the admin panel, or not at all. We’re assuming you’ve already moved your files via FTP to the media/import directory before getting started. If you have got this far and want to pursue this method, it’s worth checking the following;

  • Caches are flushed and disabled – this is standard practise for a development environment
  • Indexes are refreshed to ensure correct database information is shown on the store view
  • You are referencing relative URLs from media/import in your file name, i.e. media/import/example.jpg should be recorded on the spreadsheet as /example.jpg
  • The products you are checking in the store view are visible in that view

If you find yourself constantly on Magento’s and Stack Overflow’s website, then it may be time to move on to a different solution.

add to cart cannot redirect to shopping in magento

Take a look @

/app/design/frontend/default/[theme]/template/catalog/product/view/addtocart.phtml

The default onclick method should be productAddToCartForm.submit(this). If your custom template have the same onclick method, then take a look at both base and your custom theme productAddToCartForm submit() method.

<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>

Also take a look @ Admin -> System -> Config -> Sales -> Checkout -> Shopping Cart -> After Adding a Product Redirect to Shopping Cart

contact to add captcha

https://janakbhimani.wordpress.com/2013/09/14/how-to-add-captcha-in-contact-us-form-in-magento-1-7-0-2/comment-page-1/

Create a free website or blog at WordPress.com.

Up ↑