Integrating Magento with a simple static website

user188162 picture user188162 · Oct 23, 2009 · Viewed 14.5k times · Source

Magento is an awesomely powerful ecommerce platform. That said, it is also very complex, and I'd like to know if there is a relatively simple way to utilize Magento as our mISV site's backend to fulfill orders without actually "using" Magento's framework to build the site, run the site, etc. In other words, I don't want to use the built-in CMS, etc. since we have a static website already built. I'd just like our Buy Now buttons to utilize the checkout stuff, and would like to be able to use the back-end part to keep track of orders etc. I was able to accomplish this "fairly" easily with osCommerce, but Magento is proving to be a little more difficult to wrap my head around since I've only started looking at it for a few days now.

I found another person asking this same exact question on the Magento wiki (along with several others in the forum), and none of them ever receive a reply for some reason. I noticed that there are may Magento experts on Stack Overflow, so I thought I'd give it a go here. This is an example of one question asked by someone on their wiki, and it captures the essence of what I'm trying to accomplish:

Hi, as far as I understand, all shopping cart/eCommerce solutions I see are full featured PHP driven web sites. This means that all the pages the user interacts with, are server generated, and thus, the experience, is tied to the magento framework/workflow. I’d like to integrate bits and pieces of eCommerce/shopping cart in my existing website. Effectively, I’d like to have:

1) on a product information page, a “buy now/add to cart” button that adds to a cart

2) on every page, a view cart/checkout option

3) on a checkout page, with additional content already in place, having the magento “checkout” block integrated in the page (and not the entire page generated from Magento).

Have any of you done this with Magento? This is for a simple one-product website so any advice you could share would be highly appreciated.

Answer

Wes Pomeroy picture Wes Pomeroy · Nov 10, 2009

We use a static front end with a Magento back end (www.movingpicturebooks.com). It's fairly straight-forward. The biggest challenge is that you need to hardcode your front end to specific product IDs. If you're running seperate development and production environments, it can be a real bitch to keep them in sync. But that's another subject. Here are the pieces you need:

1) Add to Cart buttons - Use this link format:

/checkout/cart/add/?product=$PRODUCTID&qty=$QUANTITY

2) Shopping Cart Link: /checkout/cart/

3) Checkout Link: /checkout/onepage/

4) My Account Link: /customer/account/

5) Login/Logout: You need to have a small bit of PHP code on every page to access the Magento session, and then depending on where it's at, render the appropriate link. Example:

<?php

$include_file = $_SERVER['DOCUMENT_ROOT'] . '/app/Mage.php';
require_once ($include_file);
Mage::app("default");
Mage::getSingleton("core/session", array("name" => "frontend"));

if (empty($session)) {
        $session = Mage::getSingleton("customer/session");
}

if($session->isLoggedIn()) {
    $login_action = "Sign Out";
    $login_url = "/index.php/customer/account/logout/";
} else {
    $login_action = "Sign In";
    $login_url = "/index.php/customer/account/login/";
}

?>

6) Skinning: You mention wanting to embed the Magento Shopping Cart stuff in your design template. It's not just the cart you need to worry about - it's My Account, Login, Forget Password, all sorts of stuff. This is the one area of Magento that's halfway documented. Do a little research and you should be able to rock it.