好的,所以我正在尝试使用我的模块向注册中添加一个字段。显然我必须添加一个属性。所以我的“安装脚本”实际上只是对客户实体的升级。但是,该模块已启用,但是当我刷新前端时,它不会运行我的安装脚本。我在前面放了一个骰子,看看它是否能击中它而不是它。
我检查了大约 7 个其他堆栈溢出问题,每个错误都非常明显。诸如配置与它所在的文件夹不匹配之类的东西。使用 customer_setup 作为名称。设置文件中的错误。我一遍又一遍地查看我的代码,我知道我错过了一些小东西。某处的一些错字......但我现在浪费了太多时间,所以我把它交给你们伟大的人。
配置文件
<config>
<modules>
<BlizzardLabs_Customer>
<version>0.1.0</version>
</BlizzardLabs_Customer>
</modules>
<global>
<fieldsets>
<customer_account>
<flavour>
<create>1</create>
<update>1</update>
</flavour>
</customer_account>
</fieldsets>
<resources>
<blizzardlabs_customer_setup>
<setup>
<module>BlizzardLabs_Customer</module>
<class>BlizzardLabs_Customer_Model_Entity_Setup</class>
</setup>
</blizzardlabs_customer_setup>
</resources>
</global>
</config>
BlizzardLabs/Customer/Model/Entity/Setup.php
class BlizzardLabs_Customer_Model_Entity_Setup extends Mage_Customer_Model_Entity_Setup {
public function getDefaultEntities() {
$entities = parent::getDefaultEntities();
// Add flavour to customer attributes
$entities['customer']['attributes']['flavour'] = array(
'label' => 'Ice Cream Flavour',
'visible' => true,
'required' => true,
);
return $entities;
}
}
BlizzardLabs/Customer/sql/blizzardlabs_customer_setup/mysql4-install-0.1.0.php
Mage::log('Installing BlizzardLabs_Customer');
$installer = $this;
$installer->startSetup();
$installer->addAttribute('customer', 'flavour', array(
'label' => 'Ice Cream Flavour',
'type' => 'varchar',
'input' => 'text',
'visible' => true,
'required' => true,
'position' => 1,
));
$attrs = array('flavour');
foreach ($attrs as $item) {
$attr = Mage::getSingleton('eav/config')->getAttribute('customer', $item);
$attr->setData('used_in_forms', array('adminhtml_customer','customer_account_edit','customer_account_create'))->save();
}
$installer->endSetup();
echo "information added to database";