2012-08-08 105 views
0

嗨,必须添加一个自定义属性给客户。所以我已经扩展了核心客户模块,这些都是涉及到的文件和目录树:Magento - 将自定义属性添加到扩展核心客户模块

//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升级不执行。有什么错误的想法?

感谢名单卢克

+0

你怎么可以这样说新的模型是用来代替Mage_Customer? – Kalpesh 2012-08-08 08:46:18

+0

@KalpeshMehta放入一个模板Mage :: log(var_export($ customer,true)),并看到该类是Nauba_Customer_Model_Customer – Luke 2012-08-08 08:52:56

+0

确实很好。现在,按照@Jerzy的建议,在config.xml中包含资源节点。 – Kalpesh 2012-08-08 08:55:50

回答

1

必须在XML定义的“资源”下的全球

<resources> 
     <nauba_customer_setup> 
     <setup> 
      <module>your module name</module> 
     </setup> 
     </nauba_customer_setup> 
    </resources> 
+0

thanx。现在我的设置已执行,但在后端的客户帐户信息部分中看不到我的属性。我正在寻找其他模块的其他升级,我本地找到一些有用的东西,但我还没有找到任何东西......任何帮助? – Luke 2012-08-08 09:19:40

相关问题