Posts tagged "Magento"

Magento OneStepCheckout A/B Test

March 6th, 2012 Posted by Public 3 comments on “Magento OneStepCheckout A/B Test”

Hi everyone,

One of my major Magento Enterprise customers just launched the onestepcheckout extsion – as an A/B test with the existing multi-step checkout process. We are using Google Website Optimizer to test the variations and I will have some data starting today.

I will update this post with results of the test. I know others have experienced a lift with this extension and I am excited to see how it works for us.

Reset “Use Secure in Front End or Admin” in Database – Magento

October 8th, 2011 Posted by Public 10 comments on “Reset “Use Secure in Front End or Admin” in Database – Magento”

I ran into an issue this week where I switched on SSL on a development site and then realized the SSL cert was not installed correctly. This is a big issue in Magento because there is no way to get back to the admin to switch it back off.

If this ever happens do the following to switch back:

1. Open up your admin panel (cPanel or other)
2. Go to phpMyAdmin (if MySql)
3. Find your Magento Database
4. Find table “core_config_data”
5. Look for the columns “web/secure/use_in_frontend” and “web/secure/use_in_adminhtml”
6. Edit both values, make them equal to “0”

After this is done you will be back in action.

CMS Block in Transactional Email Template – Magento

June 3rd, 2011 Posted by Public 0 comments on “CMS Block in Transactional Email Template – Magento”

Promotional content in order confirmation, shipping notice, etc emails are common in eCommerce – here is a tiny code snippet to make this possible in Magento (Community or Enterprise). I recently added this to the Enterprise implementation for my current customer and everything appears to be working without issue.

1. Add reference to CMS block in transactional email template

 {{block type="cms/block" block_id="ford-order-confirmation-promotions" }}

2. Create CMS block, make sure identifier of block matches.
3. Test your email

Simple right? This could be taken a step further with a little code to select a CMS block based on certain conditions (customer type, purchase history, etc). Anyone want to share that code?

Show SKU in Magento Shopping Cart

April 16th, 2011 Posted by Public 2 comments on “Show SKU in Magento Shopping Cart”

Quick code addition to display the product SKU in the shopping cart in Magento.

Copy the file “default.phtml” from here: “app/design/frontend/default/default/template/checkout/cart/item/” to your local template directory.

Something like “app/design/frontend/default/”your_template”/template/checkout/cart/item/”

Add the following under the product title:

        SKU: <?php echo $_item->getSku() ?>  


<h4 class="title"><a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->getProductName() ?> </a></h4>
        SKU: <?php echo $_item->getSku() ?>  

Auto Populate Cross Sell with Products from Current Category Magento

April 16th, 2011 Posted by Public 26 comments on “Auto Populate Cross Sell with Products from Current Category Magento”

eCommerce Data is clear – you need to have cross sell items for every product in your catalog to help conversion.  The usual process consists of manually associating items in the Magento Admin interface.  This process works fine if you have hundreds or even a few thousand items – OR – you have this data in back end systems.

What happens if you don’t have the data and you have 15,000+ items in your catalog?

  • Hire someone to associate all products?
  • Randomly apply products in your data feed?
  • Develop custom code?

All of the above items are true for my Medical Supplies business – Medical Delivered so I needed a solution.  I decided to auto assign cross sell products on the front end on product page render.

In action:


  1. The item must be “visible”
  2. The item must reside in the same category as the current item
  3. Don’t display the item from the current product detail page


  1. All products automatically have cross sells displayed
  2. No need to assign products on the back end
  3. BAD:  Less control over items displayed

This solution won’t work for everyone, if you are an advanced retailer you won’t want to lose this control but if you just want cross sells and don’t have the time/resources to define manually you can try the code below.

Path:  app/design/frontend/default/<template>/catalog/product/list/upsell.phtml

(you may need to create this path – make sure to replace <template> with your template name)

* Magento
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to so we can send you a copy immediately.
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to for more information.
* @category   design_default
* @package    Mage
* @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (
* @license  Academic Free License (AFL 3.0)
* @author        Nick Cron
* @authorweb
$_related = $this->getProduct();
// get the parent id to skip
$_parentid = $_related->getId();

if ($_related) {
// get collection of categories this product is associated with
$categories =$_related->getCategoryCollection()
->setPage(1, 1)

// if the product is associated with any category
if ($categories->count())
foreach ($categories as $_category)
$cur_category = Mage::getModel('catalog/category')->load($_category->getId());


<div><h4><?php echo $this->__('You may also be interested in the following product(s)') ?></h4></div>
<table cellspacing="0" id="upsell-product-table">



$visibility = array(

$products = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter('visibility', $visibility)


// count the number of displayed products

foreach ( $products as $productModel )       {
$_related = Mage::getModel('catalog/product')->load($productModel->getId());
$_realtedid = $_related->getId();

// prevents displaying the same product your are already on
if ($_realtedid != $_parentid && $_i<4):


<p><a href="<?php echo $_related->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($_related, 'small_image')->resize(125) ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_related->getName()) ?>" /></a></p>
<h5><a href="<?php echo $_related->getProductUrl() ?>"><?php echo $this->htmlEscape($_related->getName()) ?></a></h5>

<?php echo $this->getPriceHtml($_related, true) ?>
<?php echo $this->getReviewsSummaryHtml($_related) ?>

// increment displayed products


<?php }
<script type="text/javascript">decorateTable('upsell-product-table')</script>

Room for improvement:

  1. Display items from the back end if exist
  2. Display only items with images
  3. ..?

I hope this helps someone.  If you have any suggestions for improvement or code upgrades/fixes please let me know in the comments.

Magento: Remove auto breaks (“br/”) from product description

April 16th, 2011 Posted by Public 2 comments on “Magento: Remove auto breaks (“br/”) from product description”

By Default Magento automatically adds


html tags to product descriptions for display on the customer interface.  If you have created a nice description with the WYSIWYG Editor or imported HTML descriptions you most likely want to remove this behavior.   Luckily this is not hard to do.

1.  Find the file “description.phtml” here:  /app/design/frontend/base/default/template/catalog/product/view/description.phtml

2. Make a local copy by copying the file to your local template.  You may need to create the same path in your Magento template (you never want to change core code for upgrade reasons).

New Path: app/design/frontend/default/<template name>/template/catalog/product/view/description.phtml

3.  Remove the “nl2br” tag


<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($this->getProduct()->getDescription()), 'description') ?>


<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(),     $this->getProduct()->getDescription()), 'description' ?>

4.  Upload the file to your server.

Magento 1.5 Product Import/Export – First Take

February 28th, 2011 Posted by Public 14 comments on “Magento 1.5 Product Import/Export – First Take”

Recently I upgraded from Magento Community 1.4 to 1.5 to take advantage of the next import and export features released in 1.5.  These updates are intended to finally fix the major pain point for many Magento users – it is not easy to import or export products and customers, especially on shared servers or machines with lower resource levels.

I had a specific need to export all of my products, clean the catalog data and import back to Magento.  Here are some things I have found so far.

#1 Menu Location

The new import and export features are in “System > Import/Export > Import” and “System > Import/Export > Export” – the old/legacy profiles have been renamed “Dataflow – profiles” and “Dataflow – Advanced Profiles”

#2 Options

The first screen has two main options “Products” and “Customers” and an option for file type (.csv is the only option)

#3 Products – Detailed Options

Once you select “Products” you have the option to restrict the products included in the .csv file.  This is a much larger list of options than the previous version and nice to see.

(screenshot too large to include)

#4 Run Job

To run the job with the parameters you have specified click the “Continue” button in the lower right to create the file.

Note:  In my case I was trying to export 16,000+ products on a shared server with limited resources (my staging site) and ran into memory errors.  To fix the issue I had to restrict the products exported by setting price ranges in the export and change the ranges until I had a small enough memory usage.

#5 File Created

#5 Resulting File – Columns found in .csv

The following columns were exported:

Note: With my memory restriction I had to create a bunch of these files and manually add them all to a single excel file.

Using this method I was able to export over 16,000 SKUs from a shared server environment in a little over 1 hour.  The export job itself is very much improved from the previous versions and I am happy with the results so far.

Now on to the update and import process, I want to be able to do the following:

  • Change product titles in the export file and import them back to Magento in Bulk
  • Modify the catalog taxonomy and add/change categories by changing in the data file
  • Configure complex products (grouped, configurable, etc) directly in the data file.
  • Reload the updated data feed without experiencing memory issues and failures
  • Reindex the site to pick up the new catalog

I don’t know how many of my wish list items will work… off to begin testing.

Upgrade Magento Community from 1.4 to 1.5 via SSH

February 28th, 2011 Posted by Public 3 comments on “Upgrade Magento Community from 1.4 to 1.5 via SSH”

It’s that time of year again. The new Magento stable release is out and it’s time to upgrade to the new version. I am upgrading on my staging site first and have of course made copies of everything in case it blows up.

I am upgrading to move to the “enhanced” import/export features in – supposedly I will actually be able to export my products (16,000+).

Step 1: Generate a SSH key on Mac

Navigate to “Utilities > Terminal”

In Terminal enter the following:

ssh-keygen -t dsa

Expected Response: “Generating public/private dsa key pair.”

Provide file to save the key:

Enter file in which to save the key (/Users/macuser/.ssh/id_dsa): id_dsa

Enter a passphrase (your local password – can be anything)

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

If successful:

Your identification has been saved in id_dsa.
Your public key has been saved in
The key fingerprint is:

Step 2: Locate the key in your file directory and open it with a text editor (I used bluefish).

Copy all text and add the text to the “Public Key” configuration at your web host. This step creates the secure connection between your server and local machine.

Step 3: Load SSH key in terminal

ssh-add /Users/macuser/id_dsa

– enter passphrase

Step 4: Connect to your server

ssh <user>@<domain>.com -p<ssh port>

Step 5: If connected correctly your prompt will change the user provided in step 4. Type “ls” to list folder contents on your server.

Step 6: Download Magento

Step 7: Extract tar file

tar -zxvf magento-

Step 8: list files again and look for folder “Magento”

Step 9: Copy extracted files over existing Magento installation (MAKE SURE YOU HAVE A BACKUP)
cd magento
cp -rf * ../public_html

Step 10: Try to load the site at your URL. If you have permissions issues or 500 errors try these fixes:
– I also had to look at the error logs in my cpanel to figure out the folder that had too high of permissions. For me it was ‘erorrs’ t0 fix I did a chmod 755 on that folder.

Step 11: Load the front end URL for your store to check to see if your template files work in version 1.5+
I had the following error:
Fatal error: Call to a member function toHtml() on a non-object in /home/../public_html/app/code/core/Mage/Core/Model/Layout.php on line 529
– Googled Fix:
– This worked for me

Step 12: Login to your administrative interface (usually http://<domain>/admin)
– Once you login you should see version in the footer (upgrade is done)

Step 13: Clean up the temp files

cd ../
rm -rf magento
rm magento-

Much thanks to “veracious” in the Magento Forums for this helpful post: