まず、このスクリプトをmagentoフォルダー(index.phpが配置されている場所)内で試して、インクルードパスが相対パスになるようにします。
第二に:
<?php
require_once "app/Mage.php";
Mage::app('default'); // initialize -the- app so you could access the singletons (like sessions, quotes, etc);
$test = Mage::getSingleton('checkout/cart')->getQuote()->getData(); // load the cart singleton
var_dump($test);
// take note that there isn't a closing PHP tag.. just observing the Zend Coding standards
また、セッション関連のシングルトン(カート、見積もり)を処理する場合は、セッションID(わかっている場合)を取得して復元することをお勧めします。カスタムPHPファイルからのテストと実際のmagentoアプリからのテストでは、異なるSIDが生成されることに注意してください。どういうわけか、それを「共有」する方法を提供する必要があります。次の後に挿入しますMage:app();
:
$frontend = Mage::getSingleton('core/session', array('name' => 'frontend'));
$frontend->setSessionId($sid);