2012-12-04 58 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

那么它被破坏或工作?这是答案还是问题? –

相关问题