Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento:为组创建自定义字段并将数据传递给观察者_Php_Magento - Fatal编程技术网

Php Magento:为组创建自定义字段并将数据传递给观察者

Php Magento:为组创建自定义字段并将数据传递给观察者,php,magento,Php,Magento,我正在尝试添加一个下拉列表,用于在Magento onepage签出中选择客户组,然后我需要将该信息保存在客户配置文件中 我的账单PHTML: <div class=”select” <label for=”billing:group_id”><?php echo $this->__('Select Group') ?> <span class=”required”>*</span></label><br /

我正在尝试添加一个下拉列表,用于在Magento onepage签出中选择客户组,然后我需要将该信息保存在客户配置文件中

我的账单PHTML:

 <div class=”select”
    <label for=”billing:group_id”><?php echo $this->__('Select Group') ?> <span class=”required”>*</span></label><br />
    <select id=”billing:group_id” name=”billing[group_id]” title=”<?php echo $this->__('Customer Group') ?>” class=”validate-select”>
        <option value=””><?php echo $this->__('Select Group') ?></option>
        <?php
            $groups = Mage::getResourceModel('customer/group_collection')
            ->addFieldToFilter('customer_group_id', array('gt'=> 0))
            ->load()
            ->toOptionArray();
        foreach ($groups as $a)
        echo "<option value='".$a['value']."'>". $a['label']. "</option>";
        ?>
    </select>
</div>
My config.xml:

<customer_save_before>
    <observers>
        <qwe_customer_save_observer>
            <type>singleton</type>
            <class>Ntt_Customer_Model_Observer</class>
            <method>customerSaveBefore</method>
        </qwe_customer_save_observer>
    </observers>
</customer_save_before>

独生子女
Ntt_客户_模型_观察员
以前的顾客

有人能告诉我如何将下拉值传递给观察者吗?我一整天都在努力做到这一点:(

只有一个错误,您的组id的表单字段名是
billing['group\u id']
。请尝试下面的代码

function customerSaveBefore($observer) {
     try { 
       $customer = $observer->getCustomer(); 
       $post= Mage::app()->getRequest()->getPost('billing'); 
        $customer->setData('group_id', $post['group_id']); 
      } 
      catch ( Exception $e ){ 
          Mage::log("customer_save_before observer failed: " . $e->getMessage()); 
      } 
function customerSaveBefore($observer) {
     try { 
       $customer = $observer->getCustomer(); 
       $post= Mage::app()->getRequest()->getPost('billing'); 
        $customer->setData('group_id', $post['group_id']); 
      } 
      catch ( Exception $e ){ 
          Mage::log("customer_save_before observer failed: " . $e->getMessage()); 
      }