Magento change the currency selector dropdown to a flag list

To change the currency selector dropdown to a flag list, you can take following these steps:
1. Open file app/design/frontend/default/your_theme/template/directory/currency.phtml (or app/design/frontend/base/default/template/directory/currency.phtml)and change code from:

 <select name="currency" title="<?php echo $this->__('Select Your Currency') ?>" onchange="setLocation(this.value)">
        <?php foreach ($this->getCurrencies() as $_code => $_name): ?>
            <option value="<?php echo $this->getSwitchCurrencyUrl($_code) ?>"<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected="selected"<?php endif; ?>>
                <?php echo $_name ?> - <?php echo $_code ?>
        <?php endforeach; ?>


        <?php foreach ($this->getCurrencies() as $_code => $_name): ?>
            <a href="<?php echo $this->getSwitchCurrencyUrl($_code) ?>" onclick="setLocation(this.value);">
                    <img src="your_flag" title="<?php echo $_name ?> - <?php echo $_code ?>"/>
        <?php endforeach; ?>

1. You need to prepare a flag list (images).
2. Upload flag list to root/media/flag directory
3. Rename flags to currency’s code (EX: US Dollar -> usd.jpg, Euro -> eur.jpg, Hong Kong Dollar -> hkd.jpg…)
4. In the template file: app/design/frontend/default/your_theme/template/directory/currency.phtml (or app/design/frontend/base/default/template/directory/currency.phtml), change code to:

        <?php foreach ($this->getCurrencies() as $_code => $_name): ?>
            <a href="<?php echo $this->getSwitchCurrencyUrl($_code) ?>" onclick="setLocation(this.value);">
                    <img src="<?php echo Mage::getBaseUrl('media').'flag/'.$_code.'.jpg'; ?>" title="<?php echo $_name ?> - <?php echo $_code ?>" alt="<?php echo $_name ?> - <?php echo $_code ?>" width="20" height="20" />
        <?php endforeach; ?>

Magento – Move Currency Switcher to the Header

If you would like to move the currency switcher from the left column to the header, you can use the following instructions to do so!
Open /app/design/frontend/default/default/layout/page.xml

<block type="page/html_header" name="header" as="header">

Change to:

<block type="page/html_header" name="header" as="header">
<block type="directory/currency" name="currency" template="directory/currency.phtml"/>

Open /app/design/frontend/default/default/template/page/html/header.phtml

<?php echo $this->getChildHtml('store_language') ?>


<?php echo $this->getChildHtml('currency') ?>

Save, Upload + Clear Cache
Make sure you have imported or manually entered your Currency Rates otherwise the switcher will not appear!
Its as simple as that!!


Send newsletter queue in Admin Magento

If newsletter queue is not going to sent by default magento, try to send newsletter manually as following way. Then we can send it by different ways. Here i am going to discuss about 2 methods. Navigate to Configuration>Admin>Security, select “No” in “Add Secret Key to URLs”, save configuration. type (you will be sent to a blank page.) The news letter will send. (check in the control panel it will be showing sent) After that, you can restore the secret key to url. above is the only work around that worked for me….

Locate file ‘app\code\core\Mage\Adminhtml\Block\Newsletter\Queue\Grid\Renderer\Action.php’
add following code in that page but don’t make any change in core file, override that file
in your local directory as
‘app\code\local\Mage\Adminhtml\Block\Newsletter\Queue\Grid\Renderer \Action.php’
just copy and paste that file in this directory.
Now add the following code in line number 77 before this code $this->getColumn()->setActions($actions);
$actions[] = array(
‘url’=> $this->getUrl(‘*/newsletter_queue/sending’),
‘popup’ =>true

By default magento send only 20 recipients at time. if you want to change this number and want to send more recipients at a time change in following file.

app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php in this file change following line

$countOfSubscritions = 20;
$countOfSubscritions = 100; //change 100 with what ever number you want to change.

Both solution worked for me.

Sources: (for first solution) (for second solution)

magento error : Fatal error: spl_autoload() [function.spl-autoload]: Class

Magento error:-
Fatal error: spl_autoload() [<a href=’function.spl-autoload’>function.spl-autoload</a>]: Class Zend_Log could not be loaded in /magento/app/code/core/Mage/Core/functions.php on line 247

Solution: this error comes most of the times due to lack of disk sapce or disk quota. so you need to update the disk quota for the user. Contact hosting provider for to increase the space

Magento Best Selling Products in homepage

Magento keeps tracks of the sold item , sometimes we need to displayed the most selled product in the homepage . So for that case i find the article while searching and i am using that article in this post.
Simply create directory as app/code/local/Mage/Catalog/Block/Product and create file Bestseller.php , and paste the following code.

class Mage_Catalog_Block_Product_Bestseller extends Mage_Catalog_Block_Product_Abstract
    public function __construct()

        $storeId    = Mage::app()->getStore()->getId();

        $products = Mage::getResourceModel('reports/product_collection')
            ->addAttributeToSelect(array('name', 'price', 'small_image', 'short_description', 'description')) //edit to suit tastes
            ->setOrder('ordered_qty', 'desc'); //best sellers on top



Now we need a template to use. So for that case create the file bestseller.phtml in your design folder as following order,
app/design/frontend/*/*/template/catalog/product/bestseller.phtml . Then paste the following code

 <?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
<div class="home-page-cntr">
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
    <?php if ($i>5): continue; endif; ?>

<div class="home-page-item">
        <div class="home-page-img">
            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
                 <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(65,65); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
            <?php echo $_product->getDescription(); //also getShortDescription ?>
        <div class="home-page-txt">
            <p><a class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $_product->getName() ?></a></p>
            <?php //echo $this->helper('review/product')->getSummaryHtml($_product, 'short') //product review link ?>
            <?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
            <?php //echo $this->helper('catalog/product')->getPriceHtml($_product) ?>
            <?php echo $this->getPriceHtml($_product) ?>
            <?php echo $_product->getProductId(); ?>
            <?php if($_product->getevent_date()) {echo $_product->getevent_date();} ?>
<?php $i++; endforeach; ?>
<?php for($i;$i%5!=0;$i++): ?>
    <?php endfor ?>
<?php endif; ?> 

To use this code, you need to add the block somewhere, either via XML or in a CMS page like your home page:
To use in a CMS page, use this where you enter your content – use it where you want to this item to show up!:

{{block type="catalog/product_bestseller"  template="catalog/product/bestseller.phtml"}}

Above code is tested and implemented in Magento

Source :

WordPress:Display a loading image until the page completes loading

To get the ajax loader image until the page loads ,
First add the following code somewhere in header.

<script src="" />
<div id="loading-image">
	<img src="<?php bloginfo('template_url'); ?>/images/ajax-loader.gif" alt="Loading..." />

Then , add the css for the styling purpose

#loading-image {
	background-color: #333;
	width: 55px;
	height: 55px;
	position: fixed;
	top: 20px;
	right: 20px;
	z-index: 1;
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px;
	border-radius: 10px; /* future proofing */
	-khtml-border-radius: 10px;

Now finally add the jquery part in the footer,

jQuery(window).load(function() {

This can be used for magento site too , just need to change the portion that we include in header
Just add the line below in header.phtml

<script src="">
<div id="loading-image">
	<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif', array('_secure'=>true)) ?>" alt="Loading..." />
Source :

Magento Admin Editor – “Opener is null” Issue with Inserting Images/Files in wysiwug editor shown error in browser.js

While using wysiwug editor to insert the media image , its givs an error in browser.js thus resulting not uploading the images.
This can be overcome by comment the line below in browser.js on line number staring form 228

getTargetElement: function() {
    if (typeof(tinyMCE) != 'undefined' && tinyMCE.get(this.targetElementId)) {
        if ((opener = this.getMediaBrowserOpener())) {
            var targetElementId = tinyMceEditors.get(this.targetElementId).getMediaBrowserTargetElementId();
            return opener.document.getElementById(targetElementId);
        } else {
            return null;
    } else {
        return document.getElementById(this.targetElementId);

Replace the above line withe the line below

getTargetElement: function() {
    if (typeof(tinyMCE) != 'undefined' && tinyMCE.get(this.targetElementId)) {
        if ((notOpener = this.getMediaBrowserOpener())) {
            var targetElementId = tinyMceEditors.get(this.targetElementId).getMediaBrowserTargetElementId();
            return notOpener.document.getElementById(targetElementId);
        } else {
            return null;
    } else {
        return document.getElementById(this.targetElementId);

After changing the above line uploading the image works in wysiwug editor

Source :

Magento Remove Discount and Estimated shipping form Checkout page

To remove both Discount and Estimated shipping you need to edit checkout.xml file which is located at /app/design/frontend/base/default/layout/checkout.xml
go to line no: 89

&lt;block type="checkout/cart_coupon" name="" as="coupon" template="checkout/cart/coupon.phtml"/&gt;
&lt;block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="checkout/cart/shipping.phtml"/&gt;
&lt;block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/&gt;

comment out the highlighted portion like this

<block type="checkout/cart_coupon" name="" as="coupon" template="checkout/cart/coupon.phtml"/>
<block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="checkout/cart/shipping.phtml"/>

you are done. If still both the blocks appear clear cache. So finally your checkout page will look like this.

Magento Static Blocks

There’s more than one way to skin a hippo and adding CMS static blocks in Magento is no exception.

In case you’re unfamiliar with CMS static blocks, they are powerful little buggers in Magento’s admin that allows the site’s administrator to add and control chunks of HTML that can be displayed throughout the site. They’re perfect for seasonal banners, sale blocks, return policies, size charts and anything that would make sense to modularize to make maintaining your site easier.

But wait, aren’t there already ‘callouts’ in Magento? Well, if you’re talking about those annoying graphics of the dog and chalkboard that take editing multiple files to update then yes. Magento’s built-in callouts are a terrible way of handling regularly updated content.

Your Magento website should be as updatable as possible to keep you from getting phone calls every time a client wants to advertise a new sale. Which is exactly why we want to control these blocks from the admin. Keep in mind Magento’s upcoming release of 1.4 will be implementing a WYSIWIG editor so clients can handle their own changes instead of pestering you.

Creating a Static Block

  1. Log into your Magento store’s admin
  2. Navigate to CMS>Static Blocks
  3. Click Add New Block in the top right corner
  4. Give your block a recognizable Block Title such as Social Media Links or “Fall Sale Banner”
  5. Give your block an Identifier which will be used to call the block. Make sure the Identifier is all lowercase and separated by underscores to follow Magento’s nomenclature i.e. your_block_id
  6. Choose what store view the block belongs to. Just leave as All Store Views unless you have a good reason not to
  7. Set Status to Enabled
  8. Enter your HTML in the Content field. The editor is currently a raw HTML editor, but 1.4 will support a WYSIWIG editor. Alternately, there is a Magento WYSIWIG extention to help out.
  9. Click Save Block or Save and Continue Edit to save your settings.

You’ve set up your block, so how do you plug it into your site? Well it depends on how you need it to function, but you have several options at your disposal:

1. XML

Adding a static block to a page template is a great way to control global elements of your site, such as footer links, custom callouts in the sidebar (ultimately replacing that damn dog) and more. You can embed this code in app > design > frontend > default > your_theme > layout. Open the appropriate the file, lets say catalog.xml and plunk the following code in the block for our category view:

<block type="cms/block" name="your_block_id" before="-">
      <action method="setBlockId"><block_id>your_block_id</block_id></action>

This code will place the block “your_block_id” that you have created in the admin above the content on the category pages (notice the before=”-” attribute, which makes sure your block gets displayed before the rest of the content). This is perfect for a seasonal banner that could advertise a current sale on all product listings.

Controlling static blocks with XML is geared for content that will remain in a consistent position in your theme.

Sometimes however you gotta get down and dirty and place your CMS static block inline in your template. That’s where the next method comes in.

2. PHP

Adding your static block inline with PHP is the quickest way to get your block in your template. Let’s say you want to add a quick blurb about your return policy right after the “Add to Cart” button. The client needs to be able to occassionaly update this blurb from time to keep it current. So you open your template file that contains the “Add to Cart” button app > design > frontend > default > your_theme > template > catalog > product > view > addtocart.phtml. Find the <button> tag and right afterwards add the following code: [cc lang="php" tab_size="2" lines="40"] <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('your_block_id')->toHtml(); ?> [/cc]

This code will add the block “your_block_id” right after the button. Jobs done. This method is perfect for getting into those nooks and crannies in Magento’s vast and awkward file structure.

3. Shortcode

This method is used when you need to pull in a static block while in Magento’s admin creating CMS pages or other static blocks. A possible example would be injecting contact information into multiple CMS pages. So you create a contact static block, and then can insert the contact info on the contact us page, your privacy policy page, customer service page, etc. If the contact info changes, you simply update the static block and the changes will be reflected across all your CMS pages.

{{block type="cms/block" block_id="your_block_id"}}

This code will place the block “your_block_id” inline in your CMS page.


The whole idea of creating these static blocks is to streamline the amount of time it takes to update your site. Clients won’t have to bother you to change their 800 number. Your design team or site administer can simply FTP a new image and update the image path. Or if you own the site, you don’t have to go dumpster diving through your template files to find where you put that couple paragraphs of content.

Do you have a preferred method of adding a static blocks or creative uses of static blocks in your Magento site? Let me know in the comments.