Magento e-Commerce Few Tips, Tricks, Codes and Options

Posted by Damodar Bashyal on September 27, 2009

 

I am an e-commerce web developer. I used to use oscommerce to develop ecommerce websites but I recently started using magento.  From time to time magento really gives a hard time but I love finding the solution. I am also planning to do certification in magento, so I can call myself Magento Certified Web Developer.

When I was working with oscommerce I never documented any tips & tricks because I really didn't need it as it was so simple and easy. But as soon as I started Magento ecommerce development, I started struggling. So, I started to note down helpful tips, shortcuts and tricks. As I was just writing and emailing myself, I thought I should start writing on the blog. Now I have a blog for magento tips and tricks.

Below are few simple things I had been documenting while doing projects on Magento E-Commerce Solution. I have posted here to find faster when needed. These are just small snippets. Not detailed, easy to understand though (hopefully).

How to insert Url in the CMS pages?

{{store url=''}} will give base|store url

<div class="shop-by-category-top-image"><img src="{{store url=''}}media/shop_by_category.gif" alt="Shop By Category" width="698" height="208" /></div>

How to get item/product counts in cart?

<?php
$_cart = Mage::getModel('checkout/cart');  
echo "getItemsQty-" . ($_cart->getItemsQty()); 
echo "getItemsCount-" . ($_cart->getItemsCount()); 
echo "getSummaryQty-" . ($_cart->getSummaryQty());
?>

How to load newly created admin theme as it can't be done through admin so far?

Goto: app/code/core/Mage/Adminhtml/Controller/Action.php

//change:
->setTheme((string)Mage::getConfig()->getNode('stores/admin/design/theme/default'));
//to:
->setTheme((string)Mage::getConfig()->getNode('stores/admin/design/theme/NEWLY-CREATED-THEME-NAME'));

How to turn on Developer Path Hints?

Goto Configuration in admin -> Click on advance/developer -> select Template Path Hints 'yes' under debug.

[You need to select store website from dropdown to see this option.]

How to offer more than one currency to customers?

Goto: system -> config -> system -> currency

Make sure default config is selected. To make currency dropdown visible there should be more than one currency and all set with value.

How to add a static block to a CMS page?

First, create your static block.

You will use the identifier to call it on the cms page. Let's say, for this example, we call the identifier 'home_page_text'.

Once your static block is created, edit whatever cms page you would like this block to appear on, and simply put this code in right where you want it to show up:

//NOTE: block_id is static block identifier
{{block type="cms/block" block_id="home_page_text"}}

This is how i use it in one of the site's homepage.

<div class="homepage-top-div">
<div class="content">{{block type="cms/block" block_id="home_page_text"}}
</div>
</div>

And that's all.

How to add WYSIWYG editor to product/category description?

Download files from http://tinymce.moxiecode.com/download.php.
Copy folder "tinymce/jscripts/tiny_mce/" from downloaded and upload to the directory "/js/tiny_mce/".

Product:
Copy "app/design/adminhtml/defaut/default/template/catalog/product/edit.phtml" to your theme "app/design/adminhtml/defaut/YOUR_THEME/template/catalog/product/edit.phtml".

Category:
Copy "app/design/adminhtml/defaut/default/template/catalog/category/edit.phtml" to your theme "app/design/adminhtml/defaut/YOUR_THEME/template/catalog/category/edit.phtml".
And,
Copy "app/design/adminhtml/defaut/default/template/catalog/category/edit/form.phtml" to your theme "app/design/adminhtml/defaut/YOUR_THEME/template/catalog/category/edit/form.phtml".

Insert code somewhere in above pages:

<script language="javascript" type="text/javascript" src="getJsUrl('tiny_mce/tiny_mce.js') ?>"></script>
tinyMCE.init({
//General options
mode : "exact",
theme : "advanced",
elements : "description",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount",
//Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect,|,cite,nonbreaking",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,fullscreen",
//theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin 
});

To be continued...

UPDATE: Recently I have been pushing magento extensions to github as well, so you can download full open source code for free from there. Also, I gave magento exam and passed it. I am now a magento certified web developer. YaY! :)

 
not published on website


QR Code: Magento e-Commerce Few Tips, Tricks, Codes and Options