High traffic sites using Magento

We recently had a client debate on what is the best ecommerce solution I am a supporter of Magento the beast it may be, but it is robust. To back up my opinion I did some research although not conclusive.

Magento itself boasts some big clients using the Enterprise edition http://www.magentocommerce.com/product/enterprise-whos-using-magento

I analysed a few of these sites with leading analysis tool compete which estimates the traffic for a given url , the most high traffic site using Magento is Harbor Freight  with some 4 Million uniques at points over the last 2 years, and over 52 Million pageviews (per day) which isn’t to be sniffed at.



Other sites I checked out are:

(figures quoted per day)
Eastwood.com – 240K uniques, 2M page views
Toms.com – 1M uniques, 5M page view

Secondly with the help of BuiltWith there’s some interesting charts on Magento use:






This shows firstly that the top 1M sites Magento tops the usage worldwide, drilling down in to the most popular 10,000 Magento still tops the opensource solutions with the only other platform osCommerce coming close. Finally in the migration Magento has the highest migration to the platform from other platforms.

In all it’s good evidence to support using Magento now and for high traffic websites. What this does not show is the set up and configuration that may be needed to tweak Magento to run on high traffic sites.

Magento fix for Unable to reindex Product Flat Data – Stuck on Processing. ‘SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row

If you’ve moved across sites from a development to live site or your encountering this error after importing/exporting then here’s the solution that works every time.

1. Search for “catalog_product_flat” . Under my installation its called catalog_product_flat_1

2. Then in mysql run:


DROP TABLE catalog_product_flat_1

3. Last step open up SSH and run (or do this from the Magento admin)

php path/to/shell/indexer.php --reindex catalog_product_flat or navigate to the /shell directory and run php indexer.php --reindex catalog_product_flat

You should get “Product Flat Data index was rebuilt successfully”

Clean up linux boot partition

If your boot partition is getting full and your running the machine as a server and have no GUI you can run this command to remove all those unecessary kernel images if you update frequently they can take up quite a bit of space.

dpkg --get-selections|grep 'linux-image*'|awk '{print $1}'|egrep -v "linux-image-$(uname -r)|linux-image-generic" |while read n;do apt-get -y remove $n;done

You may also need to update GRUB  /usr/sbin/update-grub after this has completed.

Checking for a whole number in php

There may be a simpler way but I didn’t come across one except this handy function when dealing with decimal numbers.

//is_wholeNumber(string $value)
//Returns TRUE if a WHOLE NUMBER
//Returns FALSE if anything else (Float, String, Hex, etc)
function is_wholeNumber($value)
	if(preg_match ("/[^0-9]/", $value))
	{	return FALSE;	}
	return TRUE;

There is also ctype_digit but this seems to return false when using addition like so:

$numeric_string = '1'+'1';
$integer = 1+1;

if(ctype_digit($numeric_string)) { echo "true";} else { echo "false"; }  // false
if(ctype_digit($integer)){ echo "true";} else { echo "false"; }          // false 

if(is_numeric($numeric_string)){ echo "true";} else { echo "false"; }    // true
if(is_numeric($integer)){ echo "true";} else { echo "false"; }           // true

Both equal 2 yet ctype_digit returns false? , is_numeric works here but as i’m dealing with decimal places this returns true when it is not a whole number.

Credit for the function due to http://davidwalsh.name/php-validatie-numeric-digits

Javascript function to return device type

Here’s a simple JS function to return the type of device based on screen size and some other helpful variables for the main manufacturers.

// mobile check
function checkForMobile() {

	var x = screen.width;
	var y = screen.height;
	var agent = navigator.userAgent.toLowerCase();
	var mobileOS = typeof orientation != 'undefined' ? true : false;
	var touchOS = ('ontouchstart' in document.documentElement) ? true : false;
	var otherBrowser = (agent.indexOf("series60") != -1) || (agent.indexOf("symbian") != -1) || (agent.indexOf("windows ce") != -1) || (agent.indexOf("blackberry") != -1);
	var iOS = (navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPad") != -1) ? true : false;
	var android = (agent.indexOf("android") != -1) || (!iOS && !otherBrowser && touchOS && mobileOS) ? true : false;
	var istablet = (/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()));
	var tablet = (istablet==true && x >= 768) ? true : false;

	// is it mobile

	if(x >= 320) {
		whichDevice = "Mobile";

	if(tablet==true) {

		whichDevice = "Tablet";


	if(x >= 800 && tablet==false) {

		whichDevice = "Desktop";


	return whichDevice;

       //sets the device type

Found something better? , please let me know.