2012-11-27 30 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