Just another WordPress.com weblog

Archive for October, 2011

Table rates shipping Method not working after migration to magento v1.6

Hello

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()
->from($this->getMainTable())
->where(‘website_id = ‘.$bind[‘website_id’])
->order(array(‘dest_country_id DESC’, ‘dest_region_id DESC’, ‘dest_zip DESC’,’condition_value DESC’))
->limit(1);

// 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 = ‘*'”,
)) . ‘)’;
$select->where($orWhere);

// 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);
$i++;
}

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.

Regards,
Meghna Vora

Advertisements

How to solve Product Flat Data and Category Products (Indexed category/products association) reindex issue

Hello

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