Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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
在使用自定义模块进行注册时,数据不会插入到magento数据库中_Magento_Module_Registration - Fatal编程技术网

在使用自定义模块进行注册时,数据不会插入到magento数据库中

在使用自定义模块进行注册时,数据不会插入到magento数据库中,magento,module,registration,Magento,Module,Registration,我创建了一个自定义模块,以便在注册页面中添加Land Phone字段。表单显示字段,但在数据库中未插入陆地电话号码。但是在eav_属性表中添加了landphone属性。唯一的问题是Land Phone的值没有插入到customer表中。我遵循了本教程: 我会给你我所做的详细代码 我的模块名是TCreg\u客户 app/etc/modules/TCreg\u Customer.xml <?xml version="1.0"?> <config> <module

我创建了一个
自定义模块,以便在注册页面中添加Land Phone字段。
表单显示字段,但在数据库中未插入陆地电话号码
。但是在
eav_属性表中添加了landphone属性。唯一的问题是Land Phone的值没有插入到customer表中。我遵循了本教程:

我会给你我所做的详细代码

我的模块名是
TCreg\u客户

app/etc/modules/TCreg\u Customer.xml

<?xml version="1.0"?>
<config>
    <modules>
        <TCreg_Customer>
        <codePool>local</codePool>
        <active>true</active>
        </TCreg_Customer>
    </modules>
</config>
<!--Landphone field begin-->
    <div class="field">
    <label for="landphone"><?php echo $this->__('Land Phone') ?></label>
     <div class="input-box">
     <input type="text" name="landphone" value="<?php echo $this->htmlEscape($this->getAddress()->getLandphone()) ?>" title="<?php echo $this->__('Land Phone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('landphone') ?>" id="landphone" />

</div>
</div>
<!--Landphone field end-->

<landphone><create>1</create><update>1</update></landphone>
app/design/frontend/mytheme/template/persistent/customer/address/edit.phtml

<?xml version="1.0"?>
<config>
    <modules>
        <TCreg_Customer>
        <codePool>local</codePool>
        <active>true</active>
        </TCreg_Customer>
    </modules>
</config>
<!--Landphone field begin-->
    <div class="field">
    <label for="landphone"><?php echo $this->__('Land Phone') ?></label>
     <div class="input-box">
     <input type="text" name="landphone" value="<?php echo $this->htmlEscape($this->getAddress()->getLandphone()) ?>" title="<?php echo $this->__('Land Phone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('landphone') ?>" id="landphone" />

</div>
</div>
<!--Landphone field end-->
我认为唯一的问题是Land phone的价值没有插入到customer表中。但我找不到解决办法。所以请帮帮我。。我怎样才能解决这个问题??任何帮助都是值得感激的


我的magento版本是1.9.1.0

您需要确保该属性在表
customer\u form\u属性中有一个条目
这将告诉magento每个customer和address表单上应该有哪些customer属性

您可以通过以下脚本片段来完成此操作。构建一个新的设置脚本,您已经提到了可以这样做,并设置属性需要在其中可用的所有表单的数组

Mage::getSingleton('eav/config')
        ->getAttribute('customer', 'attribute_code')
        ->setData('used_in_forms', array('adminhtml_customer', 'checkout_register', 'customer_account_create'))
        ->save();
表单代码选项如下所示:

  • 管理员检查
  • 管理你的客户
  • adminhtml\u客户地址
  • 结帐登记册
  • 客户\帐户\创建
  • 客户账户编辑
  • 客户地址编辑
  • 客户注册地址

出于同样的目的,请看下面的文章:希望您能从另一个角度了解如何实现这一点……不要忘记将核心文件复制到本地代码池中folder@VinodKumar这是什么别忘了将核心文件复制到本地代码池文件夹“…我提到的链接直接显示核心文件中的所有代码修改…因此我建议您将所有要编辑的文件复制到本地/Mage目录…@VinodKumar,我按照教程进行了操作,但是运气不好。数据仍然没有插入表中。我很困惑,请更具体一些。->setData('used_in_forms',array('adminhtml_customer')中的'used_in_forms'是什么。该代码放在哪里?“表单代码选项”的含义是什么?添加了一个简短的说明,基本上您需要一个新的设置脚本,并将使用的表单设置为属性所在的所有表单的数组。
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'landphone', array(
    'label'     => 'Land Phone',
    'type'      => 'varchar',
    'input'     => 'text',
    'visible'   => true,
    'position'  => 1,
    ));
Mage::getSingleton('eav/config')
        ->getAttribute('customer', 'attribute_code')
        ->setData('used_in_forms', array('adminhtml_customer', 'checkout_register', 'customer_account_create'))
        ->save();