Upgrading Magento from version 1.3 to 1.4

June 1st, 2010 § 2

Writing about this kind of stuff on my blog is quite selfish, I suppose the only person visiting this posts it’s me, when trying to remember how I have managed to fight away some computer quirk.

Anyway, today I’ve successfully managed to bring a medium-size Magento installation from 1.3 version to to 1.4 to life.

As usual I bumped into some problems along the way. This was the first:

QLSTATE[HY000]: General error: 1005 Can’t create table ‘db_xxx.catalog_product_index_tier_price’ (errno: 150)

it’s conflicting with an existing table. So go to:

/public_html/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.4.0.0.19-1.4.0.0.20.php

and remove the following from being executed:

CREATE TABLE IF NOT EXISTS `{$installer->getTable('catalog/product_index_website')}` ( ...
CREATE TABLE IF NOT EXISTS `{$installer->getTable('catalog/product_index_tier_price')}` ( ....

Next, Zend cache was bringing the whole show down:
(sometimes it displays: “There was an error processing your order. Please contact us or try again later.” on order completion)

Invalid mode for clean() method

a simple $rm -rf app/code/core/Zend/Cache/ does the trick.

Now don’t forget to change the base_urls, clean cache and index db.

Passing Variables to Child Templates in Magento

January 22nd, 2010 § 2

#mental note

Imagine if you have a Template with a Child Template aliased details_default and you want to pass a parameter to it before outputing (echoing) it.
On the template do:


$this->getChild('details_default')->setAttribute("var","something_to_pass")->toHtml();?>

and on the Child Template if you need to work with that passed variable do:

$this->getData("var"); ?>

Windows/OSX to Linux case sensitive filenames

January 10th, 2010 § 0

lib/Varien/File.php
@438 and @441 $fileName[$char] becomes strtolower($fileName[$char])

Mage/Core/Model/Design/Package.php @427 for the skin images
Catalog/Model/Product/Image.php for Catalog Product Images

//widetail code
if(!(strtolower($file) === $file)){
Mage::log("Warning Widetail: Filename $file not all in lowercase!");
$file = strtolower($file);
}

For converting your Linux files (must run on a Linux based machine) use this bash script:

#!/bin/bash

#
# Filename: rename.sh
# Description: Renames files and folders to lowercase recursively
# from the current directory
# Variables: Source = x
# Destination = y

#
# Rename all directories. This will need to be done first.
#

# Process each directory’s contents before the directory itself
find * -depth -type d | while read x
do

# Translate Caps to Small letters
y=$(echo "$x" | tr '[A-Z]‘ ‘[a-z]‘);

# create directory if it does not exit
if [ ! -d "$y" ]; then
mkdir -p “$y”;
fi

# check if the source and destination is the same
if [ "$x" != "$y" ]; then

# move directory files before deleting
ls -A “$x” | while read i
do
mv “$x”/”$i” “$y”;
done
rmdir “$x”;

fi

done

#
# Rename all files
#
find * -type f | while read x ;
do
# Translate Caps to Small letters
y=$(echo “$x” | tr ‘[A-Z ]‘ ‘[a-z_]‘);
if [ "$x" != "$y" ]; then
mv “$x” “$y”;
fi
done

exit 0

Execute it on the directory level you’d want your files and subdirs to become lowercased files.
$ ./ file_name

Upgrade from Magento 1.1.7 to 1.4

January 7th, 2010 § 0

For you guys around the block messing around Magento framework and trying to upgrade from version 1.1 to 1.4 and bounce into some Table ‘xxx_xxx’ already exists

Where xxx_xxx can be one or more of the following tables:

catalogrule_affected_product
core_flag
catalogsearch_result
remove sql
cataloginventory_stock_status

do the folowing:
Firstly rename that specific table into your favorite DB manager and if you bounce into an bla bla *.rfm error go to that specific file like

/magento1324/app/code/core/Mage/CatalogInventory/sql/cataloginventory_setup/mysql4-upgrade-0.7.4-0.7.5.php and comment the query which creates the table, in this case:/*
CREATE TABLE `{$installer->getTable('cataloginventory_stock_status')}` (
`product_id` int(10) unsigned NOT NULL,
`website_id` smallint(5) unsigned NOT NULL,
`stock_id` smallint(4) unsigned NOT NULL,
`qty` decimal(12,4) NOT NULL DEFAULT '0.0000',
`stock_status` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`product_id`,`website_id`,`stock_id`),
CONSTRAINT `FK_CATALOGINVENTORY_STOCK_STATUS_STOCK` FOREIGN KEY (`stock_id`) REFERENCES `{$installer->getTable('cataloginventory_stock')}` (`stock_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_CATALOGINVENTORY_STOCK_STATUS_PRODUCT` FOREIGN KEY (`product_id`) REFERENCES `{$installer->getTable('catalog_product_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_CATALOGINVENTORY_STOCK_STATUS_WEBSITE` FOREIGN KEY (`website_id`) REFERENCES `{$installer->getTable('core_website')}` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
*/

Update1: Due to foreign keys constrains update core_store table from MyISAM to InnoDB.
Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`irciycom_magento/weee_discount`, CONSTRAINT `FK_CATALOG_PRODUCT_ENTITY_WEEE_DISCOUNT_PRODUCT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASC).

Let me know if it helped you…

Where Am I?

You are currently browsing the Magento category at Tiago Matos’ Nest.