Единственное, что мне не хватает, - это сказать magento, что этот атрибут используется в формах, чтобы он был обработан.По сути, вы хотите включить его в различные формы, такие как 'customer_account_create', 'customer_account_edit', 'checkout_register', 'adminhtml_customer'.Поэтому вам нужно добавить в файл обновления "sql file" что-то вроде:
$usedInForms = array('customer_account_create', 'customer_account_edit', 'checkout_register', 'adminhtml_customer');
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'childname');
$oAttribute->setData('used_in_forms', $usedInForms);
$oAttribute->save();
Итак, я только что сделал это сам для своего клиента, и это на самом деле довольно просто.Вам просто нужно 3 файла в вашем модуле и редактирование пары phtml.
и т.д. / config.xml, как всегда в Magento, вам нужно настроить свой модуль.В нашем случае нам просто нужно настроить ресурсы.вот весь мой config.xml:
<config>
<modules>
<Osdave_Custattr>
<version>0.1.0</version>
</Osdave_Custattr>
</modules>
<global>
<resources>
<custattr_setup>
<setup>
<module>Osdave_Custattr</module>
<class>Mage_Customer_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</custattr_setup>
<custattr_write>
<connection>
<use>core_write</use>
</connection>
</custattr_write>
<custattr_read>
<connection>
<use>core_read</use>
</connection>
</custattr_read>
</resources>
</global>
</config>
sql / custattr_setup / mysql4-install-0.1.0.php, это файл, который добавляет атрибут в таблицы атрибутов eav,Как вы можете видеть в config.xml, он расширяет Mage_Customer_Model_Entity_Setup
.Опять же, весь файл:
<?php
$installer = $this;
$installer->startSetup();
$this->addAttribute('customer', 'erp_customer_id', array(
'type' => 'varchar',
'input' => 'text',
'label' => 'ERP Customer ID',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'default' => null,
'visible_on_front' => 1
));
if (version_compare(Mage::getVersion(), '1.6.0', '<=')) {
$customer = Mage::getModel('customer/customer');
$attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId();
$this->addAttributeToSet('customer', $attrSetId, 'General', 'erp_customer_id');
}
if (version_compare(Mage::getVersion(), '1.4.2', '>=')) {
Mage::getSingleton('eav/config')
->getAttribute('customer', 'erp_customer_id')
->setData('used_in_forms', array('adminhtml_customer', 'customer_account_create', 'customer_account_edit', 'checkout_register'))
->save();
}
$installer->endSetup();
XML-файл активации, app / etc / modules / Osdave_Custattr.xml:
<?xml version="1.0"?>
<config>
<modules>
<Osdave_Custattr>
<active>true</active>
<codePool>local</codePool>
</Osdave_Custattr>
</modules>
</config>
и теперь мне просто нужно отредактировать phtml-файлы, где я хочу, чтобы появилось новое поле, то есть регистрация, редактирование и регистрация извлечения.Вот что я добавил в свое приложение / design / frontend / mypackage / mydesign / persistent / customer / form / register.phtml:
<div class="fieldset">
<h2 class="legend"><?php echo $this->__('ERP Account Information') ?></h2>
<ul class="form-list">
<li>
<label for="erp_customer_id" class="required"><em>*</em><?php echo $this->__('ERP Customer ID') ?></label>
<div class="input-box">
<input type="text" name="erp_customer_id" id="erp_customer_id" value="<?php echo $this->htmlEscape($this->getFormData()->getErpCustomerId()) ?>" title="<?php echo $this->__('ERP Customer ID') ?>" class="input-text" />
</div>
</li>
</ul>
</div>
важно, чтобы имя поля совпадало с именематрибут.
Y вуаля, когда я регистрирую, поле заполняется в БД.
Пройдите через это, вероятно, лучшим решением для вас было бы вернуть БД и файлысделайте резервную копию, прежде чем начать редактирование, и воспроизведите мои шаги.Вам придется изменить имя, чтобы оно соответствовало вашему.
HTH