Получайте содержимое корзины за пределами Magento, но в том же домене

Мне нужно как-то сделать текущую информацию о корзине и клиенте в моем магазине Magento доступной для остальной части моего сайта, за пределами Magento.

Например, mysite.com/blog находится за пределами mysite.com/store.

В базе моего домена я запустил этот код, но он просто возвращает NULL.

require_once 'store/app/Mage.php'; umask(0); Mage::app(); Mage::getSingleton('core/session', array('name'=>'frontend')); $totalItems = Mage::getModel('checkout/cart')->getQuote(); $cart = Mage::getModel('checkout/cart')->getQuote()->getAllItems(); foreach ($cart->getAllItems() as $item) { $productName = $item->getProduct()->getName(); $productPrice = $item->getProduct()->getPrice(); } 

Related of "Получайте содержимое корзины за пределами Magento, но в том же домене"

Вот рабочий автономный файл:

 <?php require_once( 'app/Mage.php' ); umask(0); Mage::app('default'); // This has to run to authenticate customer and checkout session calls. Mage::getSingleton('core/session', array('name' => 'frontend')); // Get any customer model you desire. $oSession = Mage::getSingleton( 'customer/session' ); $oCustomer = $oSession->getCustomer(); $oCheckout = Mage::getSingleton( 'checkout/session' ); $oQuote = $oCheckout->getQuote(); var_dump( $oCustomer ); var_dump( $oSession ); var_dump( $oQuote ); var_dump( $oCheckout ); $oCart = $oQuote->getAllItems(); if( !empty( $oCart ) ) { foreach ( $oCart as $oItem ) { $sName = $oItem->getProduct()->getName(); $fPrice = $oItem->getProduct()->getPrice(); var_dump( $sName ); var_dump( $fPrice ); } } ?> по <?php require_once( 'app/Mage.php' ); umask(0); Mage::app('default'); // This has to run to authenticate customer and checkout session calls. Mage::getSingleton('core/session', array('name' => 'frontend')); // Get any customer model you desire. $oSession = Mage::getSingleton( 'customer/session' ); $oCustomer = $oSession->getCustomer(); $oCheckout = Mage::getSingleton( 'checkout/session' ); $oQuote = $oCheckout->getQuote(); var_dump( $oCustomer ); var_dump( $oSession ); var_dump( $oQuote ); var_dump( $oCheckout ); $oCart = $oQuote->getAllItems(); if( !empty( $oCart ) ) { foreach ( $oCart as $oItem ) { $sName = $oItem->getProduct()->getName(); $fPrice = $oItem->getProduct()->getPrice(); var_dump( $sName ); var_dump( $fPrice ); } } ?> 

Больше ссылок для других доменов:

Как получить доступ к сессии клиента Magento извне Magento?