Setting up Magento in XAMPP


Some of you may be banging your head against a wall trying to figure out how to setup Magento in your local XAMPP installation. Fret not aggravated peoples, we have found the answer!

As you may know, Magento is a popular e-commerce platform that can handle anything from small business to enterprise e-commerce solutions. Despite it's rather large size and not-very-optimized code, the community edition of Magento is notorious for having excessively large databases and a single .log file that is around 3GB after awhile (which is what we encountered)...

However, if you are installing a FRESH COMMUNITY EDITION (version at the time of this tutorial's birth), then we will go through the steps with you one by one!

The Process

Herein lies the process for installing magento:

Step One

Download the most recent community edition of magento!

Step Two

Go to http://localhost/phpmyadmin/ and add a new database!

Step Three

Extract the magento files in C:\xampp\htdocs\magento\ for Windows
/Applications/XAMPP/htdocs/ on Mac

Note: the above directories are the default directories and may not necessarily be the places where you installed xampp. If this is different, then extract your magento files into the ApacheDoc document root "htdocs" folder of your xampp installation.

Step Four

Next we should update our hosts and get it out of the way now. Bear in mind, the hosts file maps domain names to ip addresses. When you type a domain into your browser window, your browser will check to see if there is a matching entry for that domain name in your host file.

On Windows navigate to C:\windows\system32\drivers\etc right click on your hosts file and select edit. You will see a bunch of random numbers which are ip addresses.

Add: and save the file.

Hosts File Edit

Press the window key + r (or simply search for and/or open cmd.exe) and type the following:

ipconfig /flushdns

Flush DNS Windows

Note: to our friends who use Windows Vista, you must launch the command prompt as an administrator before you type this command!
Editing the Hosts File on Mac

Open Terminal and type the following (after each command press return):

We need to open the hosts file for editing
$ sudo nano /private/etc/hosts

Add this to the bottom of the hosts file

When done editing the hosts file, press control-o to save the file.
Press enter on the filename prompt, and control-x to exit the editor.

Now we must flush the DNS cache on our system!
$ dscacheutil -flushcache

Step Five

Assuming all went well, you are now ready to open your favorite web browser and type in and you will be redirected to the magento installation screen!

Note: we do recommend when getting to this option: We recommend that you store all session information in the file system and NOT the database.

Some options to you should choose when configuring your database information:

  • Skip URL Validation
  • Use Apache Server Rewrites

As you process through the installation process, please be patient. Do NOT click multiple times on any field especially the page where you enter in database information. Magento has a very extensive database and therefore it takes time to install and add all of the tables and populate those tables with relevant information.

Step Six

That's it! You should have a fully functioning Magento application on your XAMPP installation!

Fixing T_PAAMAYIM_NEKUDOTAYIM with Clever CMS in Magento 1.6


After a recent upgrade to Magento and using Clever CMS, we realized there was an issue on our frontend! We saw a weird error we had never seen before with an older version of Clever CMS.

Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /home/your_account/public_html/app/code/community/Clever/Cms/Model/Page.php on line 101

Some of you might be wondering what in the world who/what T_PAAMAYIM_NEKUDOTAYIM actually is. Aside from being an influential programmer, a T_PAAMAYIM_NEKUDOTAYIM is the double colon system that PHP uses to call a parent class's static field, static constant, static variable, or static method. Thankfully, resolving this error is easy to fix.

Step 1

Open your favorite text editor or log into your web host via terminal and go to public_html/app/code/community/Clever/Cms/Model/Page.php. Open the file with your text editor or a edit or vim command in shell. Go to line 101 or find the method called getChildren.

public function getChildren()
        $collection = $this->getCollection();
        // $collection->setOrder('position', $collection::SORT_ORDER_ASC);
        $collection->setOrder('position', $collection->SORT_ORDER_ASC);
            ->where('main_table.store_id = ?', $this->getStoreId())
            ->where('main_table.parent_id = ?', $this->getId());

        return $collection;

Notice the line commented out with $collection::SORT_ORDER_ASC. We need to change the :: to a -> because $collection is an object calling a static constantin the Mage_Cms_Model_Page class. In fact, if we look in Magento we'll see that this static constant doesn't even exist in this class or it's parent class (Mage_Core_Model_Abstract)!

That should fix anyone's issue with this error!

"How did you hear about us?" in Magento 1.5


One of our most recent projects required us to get a grip on the Magento e-commerce platform. The client was request a "How did you hear about us" feature on the Magento onepage checkout form. Rather than spend the time to learn exactly how Magento is setup and learn a new flavor of PHP, we figured a module would be best. Luckily, we found free module that did the trick!

Inchoo is the company that created this module. The module essentially places a drop down option by default under it's own tab in the Magento onepage checkout.

Here is an example of the default usage of this module:

In order to get this module to work properly in Magento 1.5, we need to edit some files.


First, we need to download the extension and unzip the files. Open your favorite FTP client and drag and drop the files into the root directory of your Magento 1.5 installation.

Once the extension is in place, log into the admin side of Magento and navigate to System > Configuration > Design > Admin Theme. We need to enter in custom into the admin theme field and save.

Once that is done, we need to dig around in the files to make this extension compatible with our English-speaking users and allow the extension to actually work!.

Our first matter of business is we need to change the text which appears on the onepage checkout form. Go to app/code/local/Inchoo/Heared4us/Block/Onepage/heard4us.phtml

Change this:

$this->getCheckout()->setStepData('heared4us', array(
        'label'     => Mage::helper('checkout')->__('Where did you heared for us'),
        'is_show'   => true

To this:

$this->getCheckout()->setStepData('heared4us', array(
        'label'     => Mage::helper('checkout')->__('How did you hear about us?'),
        'is_show'   => true

Next, we want to alter the text in the admin view to display correctly. Open app/design/adminhtml/default/custom/template/sales/order/view/info.phtml

Around line 134 (if you have line numbers, if not then search for "Where did you heared about us") we want to replace this:

<h4 class="icon-head head-heared4us"><?php echo Mage::helper('sales')->__('Where did you heared about us') ?></h4>

With this:

<h4 class="icon-head head-heared4us"><?php echo Mage::helper('sales')->__('How did you hear about us?') ?></h4>

The code above will change the text on the checkout form with proper English syntax and grammar...

Open your favorite IDE or text-editing program (notpad or textedit) so we can edit this code.
Note: if you don't have access to edit the files before you place them on the server then edit the files on your local system and then upload them to the server.

One of the first lines of PHP code we will see is the following:

$_options = array(
	$this->__('Sea Star Online'),
	$this->__('Sea Star Magazine'),

This block of code controls the items that are in our drop down menu on the onepage checkout form. If you would like to use this drop down, the continue on reading how to customize it. If you would like to use a text field, then click here

Editing these drop down items is very easy. All we have to do is replace the text between the ' and ' inside of the parenthesis. For example:

$_options = array(
	$this->__('A Friend'),
        $this->__('Saw it in a Store')

We edited the text to suit our needs and we even added an option to the drop down. It's important that each item in the array have a comma after it with the exception of the last item in the array. Be sure the structure is always as follows:

$_options = array(
       $this->__('Item 1'), //first item,
       $this->__('Item 2'), //second item, many more items,
       $this->__('Item 100), //100th item,
       $this->__('Last Item') //final item (no comma after this)

If you want a text field where the user can enter in their information just like this:

Then we only need a few minor tweaks before we can achieve this feature!

First, we need to comment out the array which contains our drop down menu options.

/*$_options = array(
	$this->__('Sea Star Online'),
	$this->__('Sea Star Magazine'),
$_options = '';

Next, we want to comment out the drop down menu itself:

<?php /*
	<select id="getvoice" name="getvoice">
		<?php foreach($_options as $_option): ?>
			<option value="<?php echo $_option ?>"><?php echo $_option ?></option>
		<?php endforeach; ?>
		<option id="getvoice-other" value="<?php echo $this->__('Other') ?>"><?php echo $this->__('Other') ?></option>
*/ ?>

Finally, we want to put in our text input field, here is an example:

<div class="field">
	<div class="field-label"><label for="getvoice">How did you hear about us?<em>*</em></label></div>
	<div class="field-field"><input type="text" name="getvoice" id="getvoice" /></div>

Note: there are extra div's in here that were created for formatting purposes. Here is the css that wwas used to style this field. If you decide to use this css, be sure to put it in /skin/frontend/default/yourtheme/css/skin.css

#checkoutSteps #opc-heared4us .field {width:100%;}
#checkoutSteps #opc-heared4us .field .field-label {font-weight:bold; color:#00c4ff;}
#checkoutSteps #opc-heared4us .field .field-label em {color:red;}

Typically, it's good just to keep the variable set to an empty string, you never know if it is being used by something else and an error will occur.

Getting the Values to show in the Admin Area

There are few things we must do in order to enable either of options or the user input value to show in the admin side. We must navigate to app/code/local/Inchoo/Heared4us/sql/mysql4-install-0.1.0.php and open the file with your favorite IDE of text editor.

Replace this line:

$row = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchRow($sql);

with this

$row = Mage::getSingleton('core/resource')->getConnection('core_read')->addColumn(Mage::getSingleton('core/resource')->getTableName('sales/order'), 'giftaid', 'TEXT NULL');

Next, we need to add a new field to a table so we need database access with a tool like phpMyAdmin. If you do not have database then contact your administrator and request the following change.

ALTER TABLE sales_flat_order ADD heared4us TEXT;

If you don't know your database login info you can find it at app/etc/local.xml. If you have SSH access you can do the following:

mysql -u mage_user -p mage_db
USE mage_db;
ALTER TABLE prefix_sales_flat_order ADD heard4us TEXT;

Be sure you add semi-colons otherwise MySQL will complain. It is imperative you know your prefix as well. You can find this information in your local.xml file along with your database credentials.

If you do have database access with phpMyAdmin, select your magento database and click on the SQL field. Copy and paste the SQL above and then press "Go". See the image for details.


The end result should be under each new order. You will see a "How did you hear about us?" field and the option/text the user typed in will show as follows:


Go to Top