Magento数据升级将无法运行

时间:2014-11-26 00:02:27

标签: php magento module attributes

我们有一个属性是在我们现在要删除的先前升级语句中创建的。它最初是使用以下脚本创建的:

<?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,因此应该运行。而且,也许是,我还有另一个问题?

有人能指出为什么这可能没有运行或删除这些数据吗?

1 个答案:

答案 0 :(得分:0)

您可以将此用于删除属性

 $installer = $this;
 $installer->removeAttribute('customer', 'attribute_code_here');