你如何添加自定义属性客户群在Magento? [英] How do you add custom attributes to Customer Groups in Magento?
问题描述
我们是在Magento的CE 1.7.0.0,我们正在努力的新属性添加到客户群的实体。我们已经成功添加自定义属性,使用下面的安装脚本客户:
We're on Magento CE 1.7.0.0, and we're trying to add new attributes to the Customer Group entities. We've successfully added custom attributes to Customers using the following install script:
<?php
$installer = $this;
$installer->startSetup();
$setup = Mage::getModel('customer/entity_setup', 'core_setup');
$setup->addAttribute('customer', 'ussco_account_number', array(
'type' => 'varchar',
'input' => 'text',
'label' => 'USSCO Account Number',
'note' => 'Leave blank for default',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 0,
'default' => '',
'visible_on_front' => 0,
'source' => NULL,
));
Mage::getSingleton('eav/config')
->getAttribute('customer', 'ussco_account_number')
->setData('used_in_forms', array('adminhtml_customer'))
->save();
$installer->endSetup();
有没有人有任何运气做的客户群类似的东西,而不是客户?
Has anyone had any luck doing something similar with Customer Groups, rather than customers?
推荐答案
如果您在SQL安装/更新脚本来看看,你会发现这样的事情:
If you take a look at the sql installer/update scripts you will find something like this:
$table = $installer->getConnection()
->newTable($installer->getTable('customer/customer_group'))
->addColumn('customer_group_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true,
), 'Customer Group Id')
->addColumn('customer_group_code', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
'nullable' => false,
), 'Customer Group Code')
->addColumn('tax_class_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'unsigned' => true,
'nullable' => false,
'default' => '0',
), 'Tax Class Id')
->setComment('Customer Group');
正如你可以看到它的一个简单mysql4表,你只需要一个栏添加到组。这不是EAV所以你不要对一个属性的工作!
As you can see its a simple mysql4 table and you simply need to add a column to the group. It is not EAV so you dont work with attributes on that one!
新柱不会在形式或网格显示出来!您必须手动通过观察或重写 Mage_Adminhtml_Block_Customer_Group_Edit_Form
或 Mage_Adminhtml_Block_Customer_Group_Grid
通过添加一些像这样如文本字段添加这样的:
The new colum will not show up in the form or grid! You have to add this manually via observer or rewriting Mage_Adminhtml_Block_Customer_Group_Edit_Form
or Mage_Adminhtml_Block_Customer_Group_Grid
by adding something like this for e.g text field:
$fieldset->addField('your_column', 'text',
array(
'name' => 'Your_Column',
'label' => Mage::helper('customer')->__('Tax Class'),
'title' => Mage::helper('customer')->__('Tax Class'),
'class' => 'required-entry',
'required' => true
)
);
这篇关于你如何添加自定义属性客户群在Magento?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!