2012-11-27 29 views
1

我创建了一个实现了新的运输方式,以Magento的一个模块。目前该模块运行良好。Magento的:建立自己的配送方式与附加属性

送货方法示出了在onepage结帐。

class Tigerbytes_Barverkauf_Model_Carrier_Selbstabholung extends Mage_Shipping_Model_Carrier_Abstract 

现在我想扩展功能。新的运输模块不应再显示在前端。因此我添加了一个新的属性给我的模块。 (show_frontend)

config.xml中

<default> 
     <carriers> 
      <selbstabholung> 
       <active>1</active> 
       <allowed_methods>selbstabholung</allowed_methods> 
       <methods>selbstabholung</methods> 
       <sallowspecific>0</sallowspecific> 
       <model>Tigerbytes_Barverkauf_Model_Carrier_Selbstabholung</model> 
       <name>Selbstabholung</name> 
       <title>Selbstabholung</title> 
       <specificerrmsg>Zur Zeit ist die Versandmethode nicht verfuegbar</specificerrmsg> 
       <handling>0</handling> 
       <handling_type>F</handling_type> 
       <show_frontend>0</show_frontend> 
      </selbstabholung> 
     </carriers> 

    system.xml 
<show_frontend translate="label"> 
          <label>zeige im Frontend?</label> 
          <frontend_type>select</frontend_type> 
          <source_model>adminhtml/system_config_source_yesno</source_model> 
          <sort_order>1</sort_order> 
          <show_in_default>1</show_in_default> 
          <show_in_website>1</show_in_website> 
          <show_in_store>1</show_in_store> 
         </show_frontend> 

属性show_frontend示于后端和也保存在core_config_data表。现在

最大的问题是让为用户选择onepage结账送货方式时,有在对象没有show_frontend属性。

我认为,用于送货方式列表中的对象是

Mage_Sales_Model_Quote_Address_Rate 

所以我有什么扩展,即率对象知道的show_frontend属性?

回答

0

附件:

我只是想允许在前端显示出货方式。在我想要显示的后端订单的后端。

所以在collectRates()梅索德我实现了以下条件。

if(Mage::getDesign()->getArea() === Mage_Core_Model_App_Area::AREA_FRONTEND && 
     !Mage::getStoreConfig('carriers/'.$this->_code.'/show_frontend')){ 

     return false; 
    } 

现在它的工作非常完美!

1

你正在做的所有insed你模块吧?

只要做到这一点:

在您collectRates()方法,你把这个代码:

if(!Mage::getStoreConfig('carrier/selbstabholung/show_frontend')) 
    return false; 

这段代码应该做的工作。

美好的一天。

+0

该死的,你真实!谢谢。我正在考虑收集。 :-) –

+0

是的,有时候magento也可以很简单。 ;)请将答案标记为正确。 〜^ – Guerra