Art is our best work

January 29th, 2010 § 0

By my definition, most art has nothing to do with oil paint or marble. Art is what we’re doing when we do our best work.

via http://sethgodin.typepad.com/seths_blog/2010/01/making-art.html

“Cumprimentos / Best Regards” in Email Signature

January 28th, 2010 § 2

I have work with people in some big companies( and I am refering to managerial staff) who uses email signatures.

So far so good, it’s a pain in the ass to write our detailed contacts every time we send an email (and this people send them in batches everyday).

Nevertheless, I feel quite rude to add “Regads / Best wishes” or any other type of automatic goodbye note.

Best Regards / Melhores cumprimentos / Cordiales Saludos

Tiago Duarte Matos
Head of Unit 13
Division 31
Widetail Inc.
+351 936551500

If people are too lazy to write some proper warm words, why bother at all?

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"); ?>

Remove ads from webs.com free pages

January 21st, 2010 § 8

Some days ago a friend of mine had to present a personal webpage as a University assignment. He used webs.com avoiding coding HTML for simple stuff like in the mid 90’s.

A problem ocurred: he only needed the page for a couple of days and didn’t want to pay the ad-free version. I came up with the hack in javascript. Just add a HTML block in any page with adds on the sidebar and it will be dynamically removed when page loads.


window.setTimeout( 'removeads()', 500 );
function removeads(){
var element = document.getElementById('boxad');
element.parentNode.removeChild(element);
}

(to make it work just round up this code with the HTML/javascript tag). Check the “script” tag here

You can check his page

New Theme

January 21st, 2010 § 0

It was been a while I wanted to uplift the image on my internet nest.

Hope you like it, even though there are some bugs on this template…

Grep on the rescue for Magento Translations

January 21st, 2010 § 0

If you ever need to translate Magento *.csv files to any toher language you will certanly need to first find the string before translating it.

As Magento comes with some dozens of translation files with many hundrends strings do this.

$ cd app/locale/pt_PT (for Portuguese translation)
$ grep -in “string in English you are searching for” *.csv | cut -d ‘:’ -f 1,2

then open your favorite Text Editor (I use Smultron) and get to that specific line and change from:

“string in English you are searching for”,”string in English you are searching for”

to :

“string in English you are searching for”,”string em Inglês que está a procurar”

Production to Development MySQL Sync

January 17th, 2010 § 0

#this is a another mental note and guide to those who want a fast solution for Prod to Dev MySQL Sync

  • Use AutoMySQLBackup for Daily/Monthly/ backups on the development server.
  • On the Production machine run some simple commands

scp -r user@dev.server.com://backups/daily/mysql_database_name/* .
gzip -d *.gz
mysql -u root -ptiagofilipe < *.sql

Later a MySQL replication server will join the party. Any thoughts or sugestions on this?

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

Configure Extra Gmail account via POP3 using Google Apps Custom Email

January 8th, 2010 § 0

picture-9
picture-10

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 viewing the archives for January, 2010 at Tiago Matos’ Nest.