我们有一个在以前的升级语句中创建的属性,我们现在想要删除。它最初是使用以下脚本创建的:
<?php
$installer = new Mage_Customer_Model_Entity_Setup('core_setup');
$installer->startSetup();
$vCustomerEntityType = $installer->getEntityTypeId('customer');
$vCustAttributeSetId = $installer->getDefaultAttributeSetId($vCustomerEntityType);
$vCustAttributeGroupId = $installer->getDefaultAttributeGroupId($vCustomerEntityType, $vCustAttributeSetId);
$installer->addAttribute('customer', 'custom_id', array(
'label' => 'Custom ID',
'input' => 'text',
'type' => 'varchar',
'forms' => array('adminhtml_customer'),
'required' => 0,
'user_defined' => 1,
));
$installer->addAttributeToGroup($vCustomerEntityType, $vCustAttributeSetId, $vCustAttributeGroupId, 'custom_id', 0);
$oAttribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'custom_id');
$oAttribute->setData('used_in_forms', array('adminhtml_customer'));
$oAttribute->save();
$installer->endSetup();
以上对我们很有帮助,但我们不再需要这个custom_id。因此,我创建了以下升级:
<?php
$installer = new Mage_Customer_Model_Entity_Setup('core_setup');
$installer->startSetup();
$vCustomerEntityType = $installer->getEntityTypeId('customer');
$vCustomerCustomIdAttribute = $install->getAttribute($vCustomerEntityType, 'custom_id');
$installer->removeAttribute($vCustomerEntityType, $vCustomerCustomIdAttribute);
$installer->endSetup();
我保存了这个,我认为它应该简单地删除此属性,但它没有。我转到管理部分,字段和数据仍然存在。我试图清除magento缓存,甚至手动删除它以使它无济于事。我已经搜索过,但似乎看不到我的问题出在哪里。
此外,此文件名为 mysql4-upgrade-0.1.22-0.1.23.php
,目前其core_resource显示 0.1.22,因此应该正在运行。而且,也许是这样,我还有另一个问题?
谁能指出为什么这可能没有运行或删除这些数据?
你可以用它来删除属性
$installer = $this;
$installer->removeAttribute('customer', 'attribute_code_here');