2013-05-30 17 views
0

在collectRates方法shippingModule,我已經建立了幾個值:的Magento得到航運collectRates()屬性在觀察者

$method->setCarrier('test_customrate'); 
$method->setCarrierTitle($this->getConfigData('title')); 
$method->setMethod('test_customrate'); 
$method->setMethodTitle($this->getConfigData('name')); 
$method->setPrice($this->getConfigData('price')); 
$method->setCost(2); 
$method->setUsername($this->getConfigData('username')); 
$method->setPassword($this->getConfigData('password')); 
$result->append($method); 

當存儲在結賬會話這些價值? 我無法在任何地方找到它們。

我現在已經發現,在觀察者的下面提到的代碼中,我可以得到如上所述的一些值。但是,有些值,如成本,用戶名和密碼不在這裏。

$rates = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress() 
->getShippingRatesCollection(); 


foreach ($rates as $rate) { 

Mage::log($rate->getData()); 

} 

這個檢索以下結構的東西:

2013-06-01T15:36:10+00:00 DEBUG (7): Array 
(
[rate_id] => 852 
[address_id] => 93 
[created_at] => 2013-06-01 15:36:06 
[updated_at] => 2013-06-01 15:36:09 
[carrier] => test_customrate 
[carrier_title] => test_customrate 
[code] => test_customrate_test_customrate 
[method] => test_customrate 
[method_description] => 
[price] => 0.0000 
[method_title] => test123 
[error_message] => 
) 

回答

0

我工作圍繞這通過簡單地直接從運輸模塊配置得到的值。

像這樣:

法師:: getStoreConfig( '部分/組/場');

所以我剛剛從system.xml中獲取數據,就像我在collectRates()中那樣。
但是,這是相當靜態的,我仍然會更喜歡一種方法來從訂單中獲得這個。

現在,這解決了我的問題。如果有什麼知道其他方式隨時回答