Just another WordPress.com weblog

Hello,

I found error ” Maximum length of attribute code must be less then 30 symbols” in magento 1.6 above version. To resolve this error, you simply change the constant value from 30 to 60.


your-project/app/code/core/Mage/Eav/Model/Entity/Attribute.php
CONST ATTRIBUTE_CODE_MAX_LENGTH = 30;

I put the CONST ATTRIBUTE_CODE_MAX_LENGTH = 30; to 60, it resolved my problem.

Hope this post is helpful to you all..

Thanks,
Bijal Bhavsar 🙂

Advertisements

Hello Everyone,

<?php $this->getToolbarBlock()-> setTemplate('catalog/product/list/toolbar_bottom.phtml')->toHtml(); ?>

The above code will display bottom toolbar from toolbar_bottom.phtml file.

Thanks,
Bijal Bhavsar 🙂

Fatal error: Unsupported operand types in /public_html/app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php on line 657

Goto app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php

Find,
$dataRow += $stockItemRows[$productId];

Replace with,
$dataRow = array_merge($dataRow,$stockItemRows[$productId]);

Hope this helps anyone…

vishal surani

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

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

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

<?php
$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.

Thanks,
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.


file_exists(Mage::getBaseDir('media').DS.'catalog'.DS.'product'.DS.$size.DS.$image)

TO

file_exists(Mage::getBaseDir('media').DS.'catalog'.DS.'products'.DS.$size.DS.$image)

REPLACE below code

'catalog/product/'

TO
'catalog/products/'

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.

Thanks,
Bijal Bhavsar 🙂