2011-05-04 46 views
0

我從後端獲取數據時遇到問題,因此我可以在控制器中顯示它。Magento自定義模塊從後端獲取詳細信息

例如我有這樣的模塊:http://www.magentocommerce.com/wiki/5_-_modules_and_development/payment/create-payment-method-module

config.xml中我會添加一個路由器控制器

<frontend> 
    <routers> 
     <custompay> 
      <use>standard</use> 
      <args> 
       <module>CompanyName_NewModule</module> 
       <frontName>newmodule</frontName> 
      </args> 
     </custompay> 
    </routers> 
</frontend> 

控制器(公司名稱/ NewModule /控制器/ IndexController.php

class CompanyName_NewModule_IndexController extends Mage_Core_Controller_Front_Action { 

    protected $_order; 

    public function getOrder() { 
     if ($this->_order == null) { 

     } 
     return $this->_order; 
    } 

    public function indexAction(){ 
     $session = Mage::getSingleton('checkout/session'); 
     $session->setCompanyNameNewModuleQuoteId($session->getQuoteId()); 
     $this->getResponse()->setBody($this->getLayout()->createBlock('newmodule/redirect')->toHtml()); 
     $session->unsQuoteId(); 
     $session->unsRedirectUrl(); 
    } 

} 

塊(公司名稱/ NewModule /砌塊/ Redirect.php

class CompanyName_NewModule_Block_Redirect extends Mage_Core_Block_Abstract { 

    protected function _toHtml() { 
     $html = '<html><body>'; 
     $html.= $this->__('You will be redirected to the payment website in a few seconds.'); 
     $html.= '</body></html>'; 

     return $html; 
    } 
} 

這是問題所在。我沒有關於如何從後端獲取詳細信息的想法,我將在redirect.php塊中使用它。以及如何獲得顧客想要購買的產品細節。

我知道我需要包括模型,以便我能得到的細節,當我的print_r這個

Mage::getSingleton('checkout/session'); 

我沒有看到任何產品的詳細信息。

請分享一些知識或鏈接。你的幫助將是對magento開發者初學者的一大貢獻。謝謝。

回答

2

,你可以做你的塊類似的東西來獲得報價和使用的支付方法實例

$quote = Mage::getSingleton('checkout/session')->getQuote(); 

//to assure that you don't initiate a new instance with Mage::getModel('yourextension/model'); and always use the same instance 
$paymentMethod = $quote->getPayment()->getMethodInstance(); 

//assuming that this is implemented and returns Mage::getStoreConfig('your/config/path'); 
$paymentMethodConfig = $paymentMethod()->getConfig(); 

$products = $quote->getAllItems(); 
相關問題