2012-12-04 76 views
1

我已經使用Hwg屬性管理器擴展(管理類別,客戶和客戶地址屬性)向客戶地址(選擇地址類型商業或住宅)添加了自定義屬性。它在後端工作。但問題不適用於前端。所以,我已經加入此代碼
應用程序/設計/前端/基/默認/模板/客戶/地址/ edit.phtmlMagento前端自定義屬性值不保存數據

<li class="fields">   
       <label for="billing:addresstype" class="required"><em>*</em><?php echo $this->__('Address Type') ?></label> 
       <div class="input-box"> 
        <select name="billingaddresstype" id="billingaddresstype"> 
         <?php $collection = Mage::getResourceModel('eav/entity_attribute_option_collection');       
          $collection->setAttributeFilter(174); 
          $collection->setStoreFilter(); 
          $collection->load(); 
          $options = $collection->toOptionArray(); 
          foreach ($options as $option) { 
           echo "<option value='".$option['value']."'>".$option['label']."</option>";    
          } 
         ?> 
        </select><?php //var_dump($options); ?> 
       </div> 
      </li> 

現在組合框出現在前端。但它不保存數據。然後我檢查地址控制器中的提交表單值

$addressForm = Mage::getModel('customer/form'); 
     $addressForm->setFormCode('customer_address_edit') 
      ->setEntity($address); 
     $addressData = $addressForm->extractData($this->getRequest()); 

     var_dump($addressData); 

     break; 

它不包含我的自定義屬性值。

array(11) { ["firstname"]=> string(8) "thushara" 
     ["lastname"]=> string(11) "Mannaperuma" 
     ["company"]=> string(3) "flt" 
     ["street"]=> array(2) 
      { [0]=> string(17) "1234 Heartwood Dr" [1]=> string(0) "" } 
      ["city"]=> string(10) "Beltsville" 
      ["country_id"]=> string(2) "US" 
      ["region"]=> string(0) "" 
      ["region_id"]=> string(2) "31" 
      ["postcode"]=> string(5) "20705" 
      ["telephone"]=> string(12) "548-789-6548" 
      ["fax"]=> string(0) "" } 

我'卡在這一點。

回答

-1

我解決了它。

確保您擁有最新版本的Hwg屬性管理器擴展。

您可以使用此鏈接direct-download-magento-extension獲取擴展名爲zip文件。

這是我用來讓我的自定義屬性到前端的代碼。它正在保存數據。

<li class="fields"> 
       <?php 
        $attribute = Mage::getModel('eav/config')->getAttribute('customer_address','adtype'); 
       ?> 
       <label for="adtype" class="<?php if($attribute->getIsRequired() == true){?>required<?php } ?>"><?php if($attribute->getIsRequired() == true){?><em>*</em><?php } ?><?php echo $this->__('Address Type') ?></label> 
       <div class="input-box"> 
        <select name="adtype" id="adtype" class="<?php if($attribute->getIsRequired() == true){?>required-entry<?php } ?>"> 
         <?php 
          $options = $attribute->getSource()->getAllOptions();         
          foreach($options as $option){ 
         ?> 
          <option value='<?php echo $option['value']?>' <?php if($this->getCustomer()->getAdtype() == $option['value']){ echo 'selected="selected"';}?>><?php echo $this->__($option['label'])?></option> 
         <?php } ?> 
        </select> 
       </div> 
      </li> 

adtype是我的屬性代碼。字段名稱和ID必須是屬性代碼。

1

我試過你的代碼,但它打破了編輯頁面。

該擴展在1.9上適用於我,我使用自定義的rwd主題。
這是它對我的作品。

我打開我的主題文件夾這個文件: \ Magento的\ APP \設計\前臺\ RWD \ DEFAULT \模板\用戶\地址\ edit.phtml

在你的情況下,代碼會是這樣的:

<li class="field"> 
    <label for="adtype" class="required"> 
     <em>*</em>Adtype 
    </label> 
    <div class="input-box"> 
     <input type="text" name="adtype" id="adtype" value="<?php echo $this->escapeHtml($this->getAddress()->getAdtype()) ?>" /> 
    </div> 
</li> 
+0

那麼它被破壞或工作?這是答案還是問題? –

相關問題