Wednesday, December 5th 2012

Magento: Show out of stock configurable product options and notifications
posted @ 11:13 am in [ Magento -Technology -Web Design ]

Configurable products in Magento are difficult to handle, as they consist of multiple “Simple” products that have their own stock levels, prices etc.

These notes talk through how to add “Out of Stock” options to each of these on the Magento product page, and some extensions to provide Out of Stock Notifications when they are:

Programming: Show out of stock configurable options

Programming: How to show out of stock configurable options with Magento

Extension: Aheadworks – Product Updates Notifications ($89)

Extension: Amasty – Out of Stock Notifications ($79)

Extension: Apptha – Out of Stock Notification ($79)

Wednesday, October 24th 2012

Decoding $_F=__FILE__;$_X= Encoded PHP Files
posted @ 7:27 am in [ Decryption -Fixing Things -Magento -PHP -Technology -Web Design ]

Some PHP files we get from Extension developers for Magento have Bytecode encoding on them, which means if we want to change the functionality or layout of certain parts of the code, even if we’ve paid for it, we can’t.

Obviously this is rather frustrating, however it is possible to reverse engineer the files as follows to make the changes you need.

1. The three component parts

Each file has 3 main parts to it:




These parts are as follows:

$_F - a holder to do the ereg_replace of the obfuscater code with the unencryption keys

$_X - the encrypted PHP code

eval(base64_decode() - the decryption code for $_X

2. Getting the decryption code

To get the decryption code, we need to change the eval(base64_decode()); code to be an echo instead.

In our case above this would be:


and this gives us the decryption code for the main $_X values;


If we break this apart into it’s core lines we have:

//decode our main string with base64_decode

//replace obfuscater characters in the result with the correct ones

//replace the contents of $_R with our unencrypted file/PHP code

//run the contents of the unencrypted file/PHP code

//clear the contents of $_R so you can't access it

//clear the contents of $_X so you can't access it

3. Decrypting the encoded code

So now we just need to run the decryption code as far as it replacing the contents of $_R with the un-encrypted result, and echo that out to the screen.

Here’s the code:

//decode our main string with base64_decode

//replace obfuscater characters in the result with the correct ones

//replace the contents of $_R with our unencrypted file/PHP code

//print the contents of the unencrypted file/PHP code

4. Final code

So we end up with:

And we can now make the changes we need

Monday, July 16th 2012

Magento: Extend/Rewrite Block
posted @ 7:11 am in [ Magento -Technology -Web Design ]

To extend/rewrite an existing Block, you need to create your new extension, and your extended block and then rewrite the current block using your config.xml file.

1. Create your new extension

1.1 Folder for your blocks


1.2 Folder for your configuration file


2. Extend the block you want to extend/rewrite

2.1 Extended block


* Detailed Product Reviews
* @category Zuneta
* @package Zuneta_Review
* @author Alex Judd
class Zuneta_Review_Block_Product_View_List extends Mage_Review_Block_Product_View_List
public function getReviewUrlSection($id, $section)
return Mage::getUrl($section . '/*/view', array('id' => $id));


Here we have extended the core block, namely /app/code/core/Mage/Review/Block/Product/View/List.php with our own local version to add a new function allowing us to specify which section we would like to refer to when you view a review.

3. Extend/Rewrite the current block using our XML config.xml file

3.1 /app/code/local/Zuneta/Rewrite/etc/config.xml




The trick here is to specify within the ‘global’ section that we want to talk to the ‘blocks’ section.

Then when in the ‘blocks’ section we want the ‘review’ block to be the one begin rewritten, and as our code is 3 levels deep, we want to rewrite the ‘product_view_list’ block as that relates to /app/code/core/Mage/Review/Block/Product/View/List.php

Then we simply specify the whole structure of our block in the rewrite contents

4. Enabling our block

4.1 /app/etc/modules/Zuneta_Review.xml

We need a /app/etc/modules/Zuneta_Review.xml file in order to enable our module


5. Done!

We should now be good to go and our new function can be called, for example in my case I am modifying the product template


to specify that I want to use the ‘review’ rewrite for all my detailed review links

htmlEscape($_review->getTitle()) ?> __('Review by %s', $this->htmlEscape($_review->getNickname())) ?>

Wednesday, May 2nd 2012

Extending core events in concrete5
posted @ 7:09 am in [ concrete5 -PHP -Technology -Web Design ]

We’re building all of our content based sites on concrete5 as it fits in with our LAMP architecture and Zend Framework architecture which we implement a lot with our Magento eCommerce websites.

The platform is ready to go out of the box, but it’s a bit hard to find how to do what you want sometimes so here’s how to extend the core events (add user, login etc.) with your own code

1. Extending the core events

Events are extended using the /config/site_events.php file and contain the event you want to extend, along with the class and method you want to call when this happens, and finally the model that contains that information

Here’s my example extending the user add event, and calling my own class ‘ApplicationUser’ and the method (function) ‘setupUserJoinInfo’

Obviously you only need the PHP tags the first time you create the file and you can overwrite many events in the same file.

2. Create your class

New file outside of the core, so we’re going to create /models/application_user.php and add in our basic class definition

3. Create our method

So in my case I'm going to hook into my method 'setupUserJoinInfo' pass it the new user object (as we know this is being triggered by the 'on_user_add' event)

class ApplicationUser extends Object {

* @param User $uI
public static function setupUserJoinInfo($ui) {
/* Your own code goes here */

4. Make it do something

In my case I wanted to email the user a one time hash password when their account was registered so I used the User object and the Mail object with a template in the '/mail/' folder called 'account_creation.php' (you can borrow the hash generation code from the core user.php file/class)

It's not that scary once you get your files installed and the Helpers for Mail and Users make it pretty flexible. Good luck!



1. System events

2. Helpers -> Mail

3. Permissions -> Users

Monday, November 7th 2011

NGinx not compressing CSS and Javascript
posted @ 8:11 am in [ Fixing Things -Javascript -Magento -PHP -Web Design ]

Another challenge to catch-out the unwary, is that the latest CentOS/RedHat YUM repository version of NGinx, the fantastically fast web server we use for Magento, has some case scenarios where even though it should be compressing CSS and Javascript, it simply doesn’t!

The reason why seems to be that most definitions for what types of files NGinx should compress posted across the forums of the web, include the “text/html” type, such as:

gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/javascript text/x-js;

Now the problem with this seems to be that NGinx throws a simple warning that it has already got “text/html” defined as it does this by default, however what it then doesn’t tell you is that it IGNORES all the other definitions that come after it in the same line.

So what that means is that if you have the line above in your config file, even though you are defining for example “text/css” as being a file type to compress, NGinx will ignore this as it stops reading the line as soon as it hits the “text/html” double definition.

To fix, remove “text/html” from your line (*and while you are there you might as well just define the types we are using) and it will all work again.

Here’s my line for reference:

gzip_types text/css application/x-javascript;

Friday, September 23rd 2011

Upgrading Magento 1.5 to 1.6 – the gotchas
posted @ 3:46 am in [ Magento -PHP -Web Design ]

Magento upgrade time again, and as normal it should be really easy, but there are as expected a number of snags that come across the way so here’s the (pretty much) definitive way of how to do it and how to fix the problems/errors/snags that happen as you do!

1. Start with the official Magento upgrade guide at the link below

2. If when running your ./mage mage-setup you receive the following error message:

PHP Fatal error: Uncaught exception ‘Exception’ with message ‘Invalid login credentials’ in /path-to-your-website/downloader/lib/Mage/Connect/Ftp.php

then you have the incorrect ftp details for your site configured.

To fix this edit /path-to-your-website/downloader/connnect.cfg and change magento_root to your webserver/downloader directory and remote_config to you username/password and webserver root directory

3. If you initial page load after upgrade fails with the following error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry during upgrade

Then you need to remove constraints from your database as per the advice here which for reference involves changing your app/etc/config.xml file so that the existing initstatements change from:

<initstatements>SET NAMES utf8</initstatements>


<initstatements>SET NAMES utf8; SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0;</initstatements>

Another alternative is to remove the problematic line from the SQL upgrade script which is probably much neater [and we did both just in case]. Details of how to do that here and for reference you have to:

edit “app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-” and comment out the command starting on line 753.

4. Final ‘gotcha’ is that your JS and CSS files can refuse to load, and instead start trying to use your path-to-your-website as their root path, rather than the / path that they should do.

This seems to be due to permissions on the /path-to-your-website/media/ directory which Magento wants to write to, so make sure that the web server has write access here (normally a recursive permission change to allow group writes should do the thing and for reference that is:)

chmod -R g+w media

5. Clear your cache (safe way to do this is to change directory into your var directory and remove *, else if you include a /var in your statement you’ve wiped half your operating system if your dangerously logged in as root or su’d up!!)

cd var
rm -rf cache/* session/*

6. Good to go

Now the final thing is to fix any bugs in your themes – we found some new fatals in the Navigation skin due to not checking for parent/children objects being null – so you may get a few of those too. You can fix those with a

if($_categories != NULL) {

and matching closing } for the if statement

7. More references

A good support thread for this is on the Magento boards here

Thursday, August 11th 2011

Fixing Login problems with EPiServer due to too many incorrect password attempts
posted @ 9:41 am in [ Fixing Things -Technology -Web Design ]

EPiServer let’s you quite happily wrongly login, but then after the default amount of incorrect attempts puts you account into a locked status.

Sensible enough one would think, except that the error message on login, correct or now incorrect, never tells you this and instead just uses the same incorrect username and/or password message as before.

To correct this you need to reset your account status in the EPiServer database, and for reference it’s in the Authentication database in the aspnet_Membership table and stored in the column IsLockedOut.

To fix, simple reset the status of that field to 0 using a similar SQL query to the one below

UPDATE [Authentication].[dbo].[aspnet_Membership] SET [IsLockedOut] = 0 WHERE [LoweredEmail] = ‘[email protected]’;

Tuesday, June 21st 2011

Tuning mySQL for Magento
posted @ 10:07 am in [ Apache -Fixing Things -Magento -mySQL -Technology -Web Design ]

Magento loves using lots of mySQL processes, so therefore mySQL needs to finely tuned to achieve this.

We ran some benchmarking tests today using mysqlreport as the benchmarking tool and as you can see from the results below, mySQL caching following some of the tips in the articles below can really make a difference

1. First test

As you can see with basic caching turned on and no massive tuning we get a cache insert to prune rate of 1.31:1 and no real cache hits

query_cache_size = 8M
table_cache = 128
innodb_buffer_pool_size = 8M

__ Query Cache _________________________________________________________
Memory usage 5.89M of 8.00M %Used: 73.58
Block Fragmnt 14.66%
Hits 1.21M 157.7/s
Inserts 389.92k 50.7/s
Insrt:Prune 1.31:1 11.9/s

2. Second test with recommendations from and mysqlreport-3.5

Bigger cache better results

query_cache_size = 32M
table_cache = 512
innodb_buffer_pool_size = 256M

__ Query Cache _________________________________________________________
Memory usage 23.79M of 32.00M %Used: 74.33
Block Fragmnt 12.43%
Hits 3.50M 184.3/s
Inserts 681.81k 35.9/s
Insrt:Prune 2.55:1 21.8/s
Hit:Insert 5.13:1

Hit versus Insert of 5.13 to 1 – now that should make the world a much faster place 🙂


Wednesday, June 15th 2011

7 Magento projects to watch on GitHub
posted @ 10:28 am in [ Magento -Technology -Web Design ]

Inspired by the great presentations at the Magento Developers Paradise 2011 I’ve been following some of the code created there on GitHub and some of the presenters own projects and here’s 7 great Magento projects you should be following on GitHub:

Magento GitHub Sites

1. 2Boys1Shop / Twoboysoneshop_Configr

Multi-shop configurator shown at MDP 2011

2. alistairstead / MageTool

Tool to quickly create now Mage extension frameworks

3. dankocherga / MTool

Auto creates files for new Magento module

4. jirafe / magento-plugin

Magento plugin for Jirafe stats

5. firegento / firegento-dynamiccategory

Dynamic category

6. More Vanish options

7. Firegento

FireGento extension with core functionality for debugging Magento

Thursday, March 24th 2011

Vanessa G Fashion Show Launch
posted @ 4:32 am in [ Technology -Web Design ]

Our client, Vanessa G, launched their first collection last night with a fantastic show at The Banqueting Hall, a former palace of James 1st no less!

We recorded the video live and you can see the fantastic clothes and event below