Just another WordPress.com weblog


Table rates shipping method is not working properly in magento 1.6 or after migration to magento v1.6.

To resolve this follow below points:

1)Open file Mage/Shipping/Model/Resources/Carrier/Tablerate.php and copy it in app/code/local folder
2)Find getRate() function and replace given code in that function:

public function getRate(Mage_Shipping_Model_Rate_Request $request)
$adapter = $this->_getReadAdapter();
$bind = array(
‘website_id’ => (int)$request->getWebsiteId(),
‘country_id’ => $request->getDestCountryId(),
‘region_id’ => (int)$request->getDestRegionId(),
‘postcode’ => $request->getDestPostcode()

$select = $adapter->select()
->where(‘website_id = ‘.$bind[‘website_id’])
->order(array(‘dest_country_id DESC’, ‘dest_region_id DESC’, ‘dest_zip DESC’,’condition_value DESC’))

// render destination condition
$orWhere = ‘(‘ . implode(‘) OR (‘, array(
“dest_country_id = ‘”.$bind[‘country_id’].”‘ AND dest_region_id = ‘”.$bind[‘region_id’].”‘ AND dest_zip = “.$bind[‘postcode’],
“dest_country_id = ‘”.$bind[‘country_id’].”‘ AND dest_region_id = ‘”.$bind[‘region_id’].”‘ AND dest_zip = ””,
“dest_country_id = ‘”.$bind[‘country_id’].”‘ AND dest_region_id = ‘”.$bind[‘region_id’].”‘ AND dest_zip = ‘0’”,
“dest_country_id = ‘”.$bind[‘country_id’].”‘ AND dest_region_id = ‘”.$bind[‘region_id’].”‘ AND dest_zip = ‘*'”,
//”dest_country_id = ‘0’ AND dest_region_id = 0 AND dest_zip = ‘*'”,
)) . ‘)’;

// render condition by condition name
if (is_array($request->getConditionName())) {
$orWhere = array();
$i = 0;

foreach ($request->getConditionName() as $conditionName) {

$bindNameKey = sprintf(‘:condition_name_%d’, $i);
$bindValueKey = sprintf(‘:condition_value_%d’, $i);
$orWhere[] = “(condition_name = {$bindNameKey} AND condition_value getData($conditionName);

if ($orWhere) {
$select->where(implode(‘ OR ‘, $orWhere));
} else {

$bind[‘condition_name’] = $request->getConditionName();
$bind[‘condition_value’] = $request->getData($request->getConditionName());

$select->where(‘condition_name = “‘.$bind[‘condition_name’].'”‘);
$select->where(‘condition_value fetchRow($select, $bind);
// normalize destination zip code
if ($result && $result[‘dest_zip’] == ‘*’) {
$result[‘dest_zip’] = ”;
return $result;

This works for me like a charm. Hope it works for you also.

If it helps you don’t forget to comment me.

Meghna Vora


Getting to this point ultimately lead to the resolution. Below is the process we used to solve the reindexing issue for Product Flat Data:

1) Export all catalog_product_flat _* tables with data and structure with “Disable foreign key checks” enabled.
2) Drop all catalog_product_flat _* tables.
3) Once check in Frontend , that products are categories are visible
4) Login to Magento backend
5) Go to: System -> Index Management
6) Click “Reindex Data” next to “Product Flat Data” index

Below is the process we used to solve the reindexing issue for Category Products (Indexed category/products association):

1) Log into phpMyAdmin
2) Go to `catalog_category_product_index`
3) Click “Export”.
4) Export only structure with “Disable foreign key checks” enabled.
5) Drop the table `catalog_category_product_index`
6) With the SQL that was exported, remove the constraints at the bottom of the export. Be sure to keep the “SET FOREIGN_KEY_CHECKS” statements.
7) Click “SQL”, paste in modified SQL and click “Go”
8) Login to Magento backend
9) Go to: System -> Index Management
10) Click “Reindex Data” next to “Category Products” index

This worked for me ..Hope it will help you too.

If it helps dont forget to comment me ..

Meghna Vora

Hello All,

Below is the steps to change encoded path of image and display in listing page of magento

1) Add below funciton in Image.php project/app/Local/Mage/Catalog/Helper/Image.php
Copy the core file and place in local folder and than add the code in local file.

/*********Function added to encrypt image path**********/

public function base64_encode_image ($filename=string,$filetype=string) {
if ($filename) {

$changeFilePath = explode(‘cache’,$filename);
$changeFilePath = Mage::getBaseDir(). DS. ‘media’. DS. ‘catalog’.DS.’products’.DS.’cache’.$changeFilePath[1];

$imgbinary = fread(fopen($changeFilePath, “r”), filesize($changeFilePath));
return ‘data:image/’ . $filetype . ‘;base64,’ . base64_encode($imgbinary);

Now we will call above function in list.phtml file of project/app/design/catalog/product/list.phtml

Add below inside foreach loop

$this->helper('catalog/image')->init($_product, 'small_image')->resize(193,250);
$forFiletype = explode('.',$product_image);
$forFiletype = array_reverse($forFiletype);
$filetype = $forFiletype[0];
if(strtoupper($filetype) == 'JPG')
$filetype = 'jpeg';
$base64image = '';
$base64image = $this->helper('catalog/image')->base64_encode_image($product_image,$filetype);


And change Image tag of product same as Below:

<img src="<?php echo $this->getSkinUrl('images/spacer.png'); ?>" width="193" height="250" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" style="background:url(<?php echo $base64image;?>) no-repeat;"/>

When user save image it will save spacer image and not the original image.

I hope this post is helpful to you. If you have any question leave the comment.

Bijal Bhavsar 🙂

Hello All,

I found the way to rename product image folder from ‘product’ to ‘products’ or any name you wants.

1) First of all you have to rename folder name to the physical path of your project (i.e ‘project/media/catalog/product’ to ‘project/media/catalog/products’)

2) You need to change in 5 files under PATH = project/app/Mage/Catalog/Model:
You need to change from all media path ‘product’ to ‘products’ to below listed files.




REPLACE below code



File1: PATH / Product/Attribute/Frontend/Image.php

File2: PATH / Product/Attribute/Media/Image.php

File3: PATH / Product/Image.php

File4: PATH / Product/Media/Config.php

File5: PATH / Entity/Product/Attribute/Frontend/Image.php

I hope you will find this post helpful.. If you have any question add your comment.

Bijal Bhavsar 🙂

To Add New Rupee symbol in magento currency follow below steps:

1. Add below css and js in header.phtml of your design theme.
link rel=”stylesheet” type=”text/css” href=”http://cdn.webrupee.com/font&#8221;
script src=http://cdn.webrupee.com/js type=”text/javascript”

2. add below code in root.xml
path of file: lib/Zend/Locale/Data/root.xml open file in wordpad


currency type=”INR”

replace symbol Rs with: amp#x20B9; (use & for amp).

3. After this refersh cache from admin and manually delete cache from front var/cache folder.

Now in front end it will display new India rupee symbol.

Krupal Lakhia

Magento Transactional emails not working

IF you installed wysiwyg editor ,, then try to disable from etc/modules/Namespace_Modulename.xml

vishal surani

For example in our custom module we have to add order_id in grid, if we search by order id in grid than such type of error occurs.

SQLSTATE[23000]: Integrity constraint violation: 1052 Column ‘Order_id’
in where clause is ambiguous

to resolve such error we can add ‘filter_index’=>’main_table.order_id’ in $this->addColumn() function

$this->addColumn('order_id', array(
'header' => Mage::helper('couponcode')->__('Order Id'),
'align' =>'left',
'index' => 'order_id',
'filter_index'=>'main_table.order_id', // This parameter helps to resolve above error

Bijal Bhavsar 🙂

To generate pdf from html using tcpdf, follow the below steps:

Step1: Download tcpdf library from below link

Step2: Add tcpdf folder in your project at path :: Your_project/lib/tcpdf

Step3: Create html file at any place you wants.. Than create one function in model file.. to generate pdf like below:

public function generatePdf($couponIds)
$filename = " HERE PATH OF HTML FILE WILL COME" ; //EG: Mage::getBaseDir().'/app/locale/en_US/template/email/coupon.html' this will return file coupon.html
$logoImage = Mage::getBaseDir().'/skin/frontend/default/default/images/logo_pdf.jpg'; //logo image path
$ptemplate = file_get_contents($filename);
$couponFindReplace = array(
'##LOGO_IMAGE##' =>$logoImage ,
'##FOOTER_TEXT_IMAGE##' =>$footertextImage
//Above array is to change content dynamically.
$after_replace = strtr($ptemplate, $couponFindReplace);
$pdf_html = $after_replace;
// create new PDF document

// set document information
$pdf->SetTitle('PDF Title');
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
//set margins
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$lg = Array();
$lg['a_meta_charset'] = 'UTF-8';
$lg['a_meta_dir'] = 'ltr';
$lg['a_meta_language'] = 'en';
$lg['w_page'] = 'page';
$pdf->SetFont('times','',20); //set font of pdf and default font size is 20
//set some language-dependent strings

// add a page
$pdf->writeHTML($coupon_pdf_html, true, 0, true, true);
//$pdf->Output('test.pdf','D'); //this will create pdf and download at a time..
/*START:: To create pdf at particular location in server*/
$file_name = 'test.pdf';
$file_name_path = Mage::getBaseDir().'/media/coupons/'.'test.pdf';
@chmod($file_name_path, 0777);
/*END:: To create pdf at particular location in server*/
return $file_name;

above function will generate pdf

The above are the steps to create simple pdf..

If the above code is helpful to you than do reply….

Bijal Bhavsar:)


We all know that Paypal is not working in Magento – Multishipping..

if we want to make it work just open
in this file the variable
protected $_canUseForMultishipping = flase;
is initialized make it
protected $_canUseForMultishipping = true;

now you can use Paypal with Multishipping in Magento

vishal surani


If you have problem with Catalog Price Rules…
When we apply catalog price rules then rules are reflect to product listing and product detail
but when we add product in cart its taking original product price …

I think its magento core problem.

Any-way , lets solve it ….

open Mage/Catalogrule/Model/Observer.php
around 101st line

you have this segment …

if ($observer->hasCustomerGroupId()) {
$gId = $observer->getEvent()->getCustomerGroupId();
} elseif ($product->hasCustomerGroupId()) {
$gId = $product->hasCustomerGroupId();
} else {
$gId = Mage::getSingleton('customer/session')->getCustomerGroupId();

Now in 4th line we have code like
$gId = $product->hasCustomerGroupId();
… simply change this to
$gId = $product->getCustomerGroupId();


-Vishal Surani