首先,試試這個腳本出你的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);
我不認爲你需要包括「/app/Mage.php」,除非真的Magento的安裝在你的根(「/」)。 – nachito
Magento安裝在htdocs文件夾中。 – user1417156
如果你的PHP腳本位於同一個文件夾中,那麼執行'require_once'app/Mage.php';' – nachito