On vacation

I’m currently in holidays and be back beginning in September. Good upcoming posts about e-commerce and Magento.

Add column to product grid properly




class My_Module_Model_Adminhtml_Observer

    public function onBlockHtmlBefore(Varien_Event_Observer $observer) {
        $block = $observer->getBlock();
        if (!isset($block)) return;

        switch ($block->getType()) {
            case 'adminhtml/catalog_product_grid':
                /* @var $block Mage_Adminhtml_Block_Catalog_Product_Grid */
                $block->addColumn('COLUMN_ID', array(
                    'header' => Mage::helper('mymodule')->__('COLUMN HEADER'),
                    'index'  => 'COLUMN_ID',

    public function onEavLoadBefore(Varien_Event_Observer $observer) {
        $collection = $observer->getCollection();
        if (!isset($collection)) return;

        if (is_a($collection, 'Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection')) {
            /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */
            // Manipulate $collection here to add a COLUMN_ID column
            $collection->addExpressionAttributeToSelect('COLUMN_ID', '...Some SQL goes here...');


This come from Clockworkgeek user on a stackoverflow question. This is gold!

WordPress bash deployment script


Recently in my current company we had a client asking for a restaurant website. We’ve decided to do it with WordPress and used it as a CMS instead of a blog. Beside the fact that we needed to create the website, they also requested us to make all the maintenance of the website and their blog. What I suggested was to have a staging platform and of course the production platform.

To do make the deployment process from staging to production seamless, I’ve created a WordPress bash deployment script to easily go from staging to production. Some of you will ask me about the development platform? To do so, we’ve used a service called DeployHQ that works pretty well. It fetch all the content of your SVN repository and push it straight to the FTP. The only tricky part was for the database. I know it wasn’t clean but I made the decision to work on the same database for the staging and development part.

If you have any suggestions about improving this script do not hesitate.

Please consider the following on our installation:

# Written by Emmanuel Pays 
# Description : Use this script to deploy in production a WordPress blog that already exist on the same machine
# staging_to_production_wordpress.sh ver. 1.0
# Latest version can be found at http://blog.loopion.com/
# Todo
# - DONE - Email when deployment is done
# - Execution time for the script
# - Set version on meta or anywhere else to keep track of deployment version

# Global config
SUBJECT="${prod_uri} deployment successful"

#Staging info

#Production info

#Create backup
backup_db_filename="database_$(date +%F_%Hh%M).bak.sql.bz2"
backup_file_filename="files_$(date +%F_%Hh%M).tar.bz2"

#Create files backups
tar -cjPf ${backup_path_files}prod_${backup_file_filename} ${root_prod_path}
chown ftproot:psaserv ${backup_path_files}prod_${backup_file_filename}
echo "Backup prod files done..."
tar -cjPf ${backup_path_files}staging_${backup_file_filename} ${root_staging_path}
chown ftproot:psaserv ${backup_path_files}staging_${backup_file_filename}
echo "Backup staging files done..."

mysqldump --add-drop-table -h ${staging_uri} -u ${staging_db_username} -p${staging_db_pass} ${staging_db_name} | bzip2 -c > ${backup_path_db}${backup_db_filename}
chown ftproot:psaserv ${backup_path_db}${backup_db_filename}
echo "All backups done..."

#Copy staging database to production database
mysqldump --add-drop-table -h ${staging_uri} -u ${staging_db_username} -p${staging_db_pass} ${staging_db_name} | mysql -h ${prod_uri} -u ${prod_db_username} -p${prod_db
_pass} ${prod_db_name}
echo "Database replication to production done..."
#Copy all files from staging to production
cp -rR  ${root_staging_path}. ${root_prod_path}
echo "Files copied from ${staging_uri} to ${prod_uri}"
#Update production tables
mysql -h ${prod_uri} -u ${prod_db_username} -p${prod_db_pass} ${prod_db_name}< $EMAILMESSAGE
echo "This is email text" >>$EMAILMESSAGE
# send an email using /bin/mail

Nightly backup your WordPress database and files


After rading Using a Cron job to keep things safe I didn’t found this really a complete procedure as it only backup the database… I think it’s better to backup everything at once and we usually have some associated files like for example themes, images uploaded, etc… remaining that we don’t won’t to lost. So here is a solution to keep a copy of everything no matter what happen and unobstructive while visitors are visiting.

UPDATE 03/02/2011 -1.1:

  • Added a functionality to remove all file into the backup folder older than the specified number of days. Just set days_delete and it will delete all files older than days_delete days.
  • Added security to stop script if an error goes wrong

Just set up a cronjob and you’re good to go.

# Written by Emmanuel Pays 
# Description : Use this script to backup a WordPress blog
# wordpress_backup.sh ver. 1.1
# Latest version can be found at http://blog.loopion.com/

# Global config
set -e

#Production info
#Create backup
backup_db_filename="database_$(date +%F_%Hh%M).bak.sql.bz2"
backup_file_filename="files_$(date +%F_%Hh%M).tar.bz2"

#Create files backups
tar -cjPf ${backup_path_files}prod_${backup_file_filename} ${root_prod_path}
chown ftproot:psaserv ${backup_path_files}prod_${backup_file_filename}
echo "Backup prod files done..."

mysqldump --add-drop-table -h localhost -u ${prod_db_username} -p${prod_db_pass} ${prod_db_name} | bzip2 -c > ${backup_path_db}${backup_db_filename}
chown ftproot:psaserv ${backup_path_db}${backup_db_filename}
echo "All backups done..."

#Delete older backups
find ${backup_path_db}* -mtime +${days_delete} -exec rm {} \;
echo "Deleted last ${days_delete} database backup"
find ${backup_path_files}* -mtime +${days_delete} -exec rm {} \;
echo "Deleted last ${days_delete} files backup"

Coming soon a deployment script…

Delete all .SVN folders and files from a directory

Nice DOS command script to remove all .svn files and folders. Some guy’s don’t know already the export function of SVN…

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (
rd /s /q "%%i"

Am I a curator?

Link: Am I a curator?

En lisant cet article je me suis énormément reconnu. Pouvez vous me le confirmer ?

Il faut toujours avoir des projections pessimiste mais avoir une motivation et un morale optimiste. Non ?

Mulve.com – Mp3 Music Search and Music Downloads

Link: Mulve.com – Mp3 Music Search and Music Downloads

Ok, now we are talking! Piracy will continue and drain a lot of new users everyday. How do you want to stop that?

Mulve sounds to get 90’s and early 00’s back on the stage with Napster like software, where are we going?

Answer: in a KISS direction. Keep It Stupid Simple!

[Flash 10 is required to watch video.]

Salsa afterwork at meatpacking.

Beach… Headset… Rest… Peaceful…

Page 2 of 1112345...10...Last »