Question

I have a website structured as:

www.myEEsite.com/myMAGENTOstore

Where myEEsite is the root of the site and myMAGENTOstore is the Magento site. I'd like them to both look the same site, but I was wondering if there was a way to bring over the cart count value from Magento and display it in the header template of my ExpressionEngine site.

Was it helpful?

Solution

Take a look @ Magento cart / session data outside magento

umask(0);
require_once 'app/Mage.php';
Mage::app();

Mage::getSingleton('core/session', array('name'=>'frontend'));

$ItemsCount = Mage::getSingleton('checkout/cart')->getItemsCount();

var_dump(array(
    "ItemsCount" =>
    $ItemsCount
));

OTHER TIPS

Thanks for the help. Although that didn't work, I was able to successfully achieve with the following code...just changed the path of Mage.php according to my setup:

require_once 'app/Mage.php';
umask(0);

$app = Mage::app('default');
$app->getTranslator()->init('frontend'); 


if( ($_COOKIE["frontend"]=="") || ($_COOKIE["frontend"]=="undefined") || ($_COOKIE["frontend"]==null)  )
{
$session = Mage::getSingleton('customer/session');
session_name('frontend');}
else
{session_name('frontend');} 

Mage::getSingleton('core/session', array('name' => 'frontend'));

$className = Mage::getConfig()->getBlockClassName('checkout/cart/sidebar');
$block = new $className();
$block->setTemplate('checkout/cart/sidebar.phtml');

$cart = Mage::helper('checkout/cart')->getCart()->getItemsCount();
$carturl = Mage::helper('checkout/url')->getCartUrl();

echo $block->renderView();

echo '<br />cart items count: <a href="'.$carturl.'">' . $cart."</a><br />";
echo "cart Summary Qty: ".Mage::helper('checkout/cart')->getCart()->getSummaryQty()."<br />";

$cart_count = Mage::helper('checkout/cart')->getCart()->getSummaryQty();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top