views:

1633

answers:

3

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.

+1  A: 

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

Maybe this question will help you(look at the question, not the answer :-) ) as it shows how to add an item to the cart by linking to a certain URL which would make it possible to do this from outside of Magento.

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

Do you want to actually show the items in the cart or simply have a link to the cart/checkout? The latter would be trivial obviously.

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).

I think that should be possible, but would require you to look into the internals of Magento. To do this you would have to

  • include Magento's JS and CSS files into your site

  • fake a checkout request in Magento(by mimicing the bootstrap of Magento and injecting your own instance of Mage_Core_Controller_Request_Http with your fake URL of a checkout)

  • capture the output of the fake request(that should be possible via the ZF if you can't figure it out you can still use ob_start and the like)

  • print out the html code in your own site

If you have had experience with the Zend Framework this shouldn't be too hard for you.

As for the rest you won't have to do much really, since the (onepage) checkout is based on AJAX calls that probably don't interfere with you actual site.

I can't tell you if this is going to be as easy as with osCommerce(haven't been using it), but I'm very positive that it should doable.

André Hoffmann
+1  A: 

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.

Wes Pomeroy
A: 

Wes,

Great stuff here - your site is exactly what I'm trying to do.

However, I can't get the isLoggedIn() to behave with Magento 1.4.x - does anyone know what might have changed?

Much appreciated,

-Ed.

Edit: Just found the answer to my troubles here - http://stackoverflow.com/questions/1098871/how-to-access-magento-users-session-from-outside-magento

I have my store installed in a subdirectory (ie [webroot]/store) so the cookie that the session is looking for is in / and not in /store/

Edison Software