2013-05-30 18 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()中那样。
但是,这是相当静态的,我仍然会更喜欢一种方法来从订单中获得这个。

现在,这解决了我的问题。如果有什么知道其他方式随时回答