0

您好必须向客户添加自定义属性。所以我扩展了核心客户模块,这些是涉及的文件和目录树:

//app/code/local/Nauba/etc/config.xml

<?xml version="1.0"?>
<config>
<modules>
    <Nauba_Customer>
        <version>0.0.1</version>
    </Nauba_Customer>
</modules>

<global>
    <models>
        <customer>
            <rewrite>
                <customer>Nauba_Customer_Model_Customer</customer>
            </rewrite>
        </customer>
    </models>     
</global>   
</config>


 // app/code/local/Nauba/Customer/Model/Customer.php

class Nauba_Customer_Model_Customer extends Mage_Customer_Model_Customer
{
    function _construct()
    {
        parent::__construct();
    }
}




// app/etc/modules/Nauba_Customer.xml

<?xml version="1.0"?>
<config>
<modules>
    <Nauba_Customer>
        <active>true</active>
        <codePool>local</codePool>
   </Nauba_Customer>
</modules>
</config>






//app/code/local/Nauba/Customer/sql/nauba_customer_setup/mysql4-upgrade-1.6.2.0.2-1.6.2.0.3.php

$installer = $this;
$installer->startSetup();
/**
 * Adding custom attributes to customer
 */

$installer->addAttribute('customer', 'elite_invitation', array(
    'label'             => 'ID prodotto invito Elite',
    'type'              => 'varchar',
    'visible'           => true,
    'visible_on_front'  => false,
    'required'          => false,
    'backend'           => '',
    'frontend'          => '',
    'input'             => 'text',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE
));


$installer->endSetup();

现在该模块已启用,并使用新的自定义模型代替核心 Mage_Customer,但未执行 sql 升级。知道什么是错的吗?

谢谢卢克

4

1 回答 1

1

您必须在全局下的 xml 中定义“资源”

    <resources>
      <nauba_customer_setup>
         <setup>
             <module>your module name</module>
         </setup>
      </nauba_customer_setup>
     </resources>
于 2012-08-08T08:45:54.663 回答