2011-09-15 77 views
0

我不知道如何指定此問題,我想要的是,我必須從外部文件調用購物車頁面,其中產品ID和數量存儲在sales_flat_quote_item中表和我必須在購物車中顯示此產品。我試過打電話從Magento中的外部文件中調用購物車頁面

header('Location: ' . Mage::getUrl('checkout/cart/')); 

以及我所做的還附加了這個:請去驗證它。

$orderid=$_GET['orderId']; 
//$_GET['orderId']; 
$cusid=$_GET['customer']; 
//$_GET['customer']; 
require_once "app/Mage.php"; 
Mage::app(); 
Mage::getSingleton('core/session', array('name'=>'frontend')); 
Mage::getSingleton('customer/session')->loginById($cusid); 
$sql = Mage::getSingleton('core/resource')->getConnection('core_write'); 
$result=$sql->query('select 
sales_flat_quote_item.product_id,sales_flat_quote_item.weight,sales_flat_quote_item.qty,sales_flat_quote_item.price 
from sales_flat_quote left outer join sales_flat_quote_item on sales_flat_quote.entity_id=sales_flat_quote_item.quote_id 
Where sales_flat_quote.entity_id='.$orderid); 

while($row=$result->fetch(PDO::FETCH_ASSOC)) 
{ 
$pid=$row['product_id']; 
//print_r($id); .'&qty='.$qty 
$qty=$row['qty']; 
//print_r($qty); 
} 
$carthelp = Mage::helper('checkout/cart')->getQuote()->getId(); 
//$cart = Mage::getSingleton('checkout/cart'); 
//$cart->save(); 
/*$cart = Mage::getSingleton('checkout/cart')->loadbyId($carthelp); 
$cart->save(); 
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);*/ 
//echo Mage::getUrl('../index.php/checkout/cart/'); 
//header('Location: '.Mage::getUrl('../index.php/checkout/cart/')); 
/*$url = Mage::getModel('core/url') 
         ->getUrl("/../index.php/checkout/cart/index"); 
         Mage::app() 
       ->getResponse() 
       ->setRedirect($url); 

      Mage::app() 
       ->getResponse() 
       ->sendResponse(); 
header('Location: ' . $url); */ 
//header('Location: ' . Mage::getUrl('../index.php/checkout/cart/')); 

但被重定向到空購物車頁面。

我試圖找出超過24小時,但結果是一樣的。請幫幫我。

在此先感謝。

回答

1

感謝安東,

我終於弄明白了。 我們打電話車之前報價-ID加載到該結賬會議

Mage::getSingleton('checkout/session')->setQuoteId($orderid); 
$cart = Mage::getSingleton('checkout/cart'); 


header('Location: '.Mage::getUrl('../index.php/checkout').'cart'); 
1

你這樣做有點不對。儘量先設定一些目標:

  1. 包括Magento的資源
  2. 獲取你需要
  3. 將它們添加到購物車的所有項目/報價
  4. 重定向到購物車頁面
+0

安東,我已經加入**「require_once 」應用程序/ Mage.php「; 法師::應用程序() ;「**。是否有任何其他資源文件magento?並且我在** sales_flat_quote_item和sales_flat_quote **中添加了項目,我將如何重定向到購物車頁面?請幫幫我... –