Add order history comment in Magento 1.9

The method used in older version was deprecated.
The new methods are:
– $order->addStatusHistory($historyItem)
– $order->addStatusHistoryComment(“Comment”)

If you also have to set the Customer Notification flag, you should rather use the first option by creating first a Mage_Sales_Model_Order_Status_History object.

$historyItem = new Mage_Sales_Model_Order_Status_History();
$historyItem->setComment(‘Order confirmation e-mail sent by cronjob’);


Updating Google Analytics Tracking on your Magento e-shop

Google Analytics has recently changed the tracking scripts from ga.js to a more optimised version analytics.js that can be used if you set your analytics account to “Universal tracking”
Yet, Magento’s Google Analytics module is still using the old ga.js.
Of course, there are a couple of new plugins that claim to fix this, but why use a plugin to slow down your shop instead of updating 2 files and not affecting in any way the performance of your website?

Wait! Did I say updating? That should already ring a bell for a Magento developer.
The internet is full of blog articles and answers on StackOverflow advising to actually edit the existing GoogleAnalytics Module and Template files.
One could never be more wrong than that. It’s one of the first things a developer should learn about developing and extending Magento features. Never touch the core/default Modules and Templates. Create new ones under the “local” folder.

This, together with the Google Analytics Universal Tracking documentation should give you all the necessary hints and information in order to update your tracking code.

If you still can’t get it done, contact me and we can talk about contracting me to do it for you, or contracting me to provide you with a training on how you can do it yourself. 

Mac OS X 10.9 Mavericks and PHP

I was waiting the official release of Mavericks since about half a year. I was positively surprise to find out the update came free of charge. So I updated my Mac OS the moment the update was made available on AppStore. It was no surprise to see the upgraded versions of PHP, Ruby, Python, mysql and so on. It was nevertheless no surprise to see that the PHP configuration would not completely meet my development requirements. One of the most frustrating features missing from the PHP installation was the Intl package. I can hardly understand how Apple would miss compiling PHP with the Intl package, as this is required by the Locale class (yes, internationalisation is the key word here). One could say PECL will handle that for you automatically. Been there, done that, failed! Reason: PECL does nothing else but download the package and tries to compile it against the php sources. But a freshly installed MacOS has almost no sources for any of the software installed on your machine. And since we don’t have any official package manager, we should download, configure and compile ourselves everything we need. There are a lot of users who would advocate using an unofficial package manager (like mac ports or homebrew) but I’m a geek, I’d rather compile everything myself and have some more fun while I’m at it. Also, since it’s a fresh OS realease/update, I’m not sure if those package manager are still working flawlessly Now, let’s start our little adventure: downloading sources and compiling PHP and its modules. I’ll present you here a list of links where you can download the sources of the packages that come with Mavericks.

  • PHP 5.4.17 (or, since you’re at it, why not upgrade your PHP version to the latest stable release PHP 5.5.5 ?)
  • Apache 2.2.24
  • Open SSL (Package is required since the default compilation options of PHP on Mavericks contains –with-openssl .I recommend downloading the latest stable version)
  • Zlib ( –with-zlib )
  • BZIP2 ( –with-bz2 )
  • cURL ( –with-curl )
  • iconv ( –with-iconv )
  • LDAP ( –with-ldap=/path/to/executable )
  • BerkeleyDB ( required by LDAP installation )
  • SASL2 ( –with-ldap-sasl=/path/to/executable )
  • LibEdit ( –with-libedit=/path/to/executable )
  • LibTidy ( –with-tidy )
  • autoconf  (required to compile LibTidy )
  • automake (required to compile LibTidy )
  • libtoolize ( required to compile LibTidy )

Each package comes with a readme or install.txt file which explains how to compile it.
Almost all of them only require a

sudo make install

In some cases you would also have to specify a path there to install the library. Everybody recommends using /usr/local for compiling/installing yourself anything you want to compile manually. This also has a reason. If by any chance Apple decided to support ONLY the version and specific configuration delivered with the OS, you would be able to switch back to it without having to re-install the hole operating system.

Before compiling PHP, first check which is the compile option used for the OS-default installation of PHP.
Try to stick to that compile options and add new options that you require, or remove the options that you know for sure it would create problems for your project ( I’ve worked on a project that specifically required to disable the suhosin plugin for PHPm which comes enabled by default to most of the PHP installations )

Now run the ./configure command with all the options you need, followed by “make” and “sudo make install”.
Giving that you had a successful compilation, you will now have PHP freshly re-configured/re-installed and you can proceed further with your project’s development.
After this freshly re-compile, you can now also use PECL to install new packages and modules.

This is not a complete guide, but I will try to improve it bit by bit.
If you have any suggestions or if you tried the above suggestions and encountered errors, please send me a message and I will try to cover those problems here.