1
votes

I cant create custom customer attribute.

Xkey\
Xkey\Cadastros\
Xkey\Cadastros\etc\config.xml
Xkey\Cadastros\Helper\Data.php
Xkey\Cadastros\Model\
Xkey\Cadaestros\Model\Entity\
Xkey\Cadaestros\Model\Entity\Setup.php
Xkey\Cadaestros\sql\
Xkey\Cadaestros\sql\cadastros_setup\
Xkey\Cadaestros\sql\cadastros_setup\mysql4-install-0.1.0.php

Config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Xkey_Cadastros>
            <version>0.1.0</version>
        </Xkey_Cadastros>
    </modules>
    <global>
        <helpers>
          <cadastros>
            <class>Xkey_Cadastros_Helper</class>
          </cadastros>
        </helpers>
        <resources>
            <cadastros_setup>
                <setup>
                    <module>Xkey_Cadastros</module>
                    <class>Xkey_Cadastros_Model_Entity_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </cadastros_setup>
            <cadastros_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </cadastros_write>
            <cadastros_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </cadastros_read>
        </resources>
    </global>
</config>

mysql4-install-0.1.0.php

<?php  
    $installer = $this;
    $installer->startSetup(); 

    //$setup = Mage::getModel('customer/entity_setup','core_setup');
    //$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

    $installer->addAttribute('customer','rede_grupo', array(
            'type' => 'varchar',
            'input' => 'text',
            'label' => 'Rede Grupo',
            'global' => true,
            'visible' => true,
            'required' => false,
            'user_defined' => true,
            'visible_on_front' => false,
            'default' => ''
        ));

    if(version_compare(Mage::getVersion(), '1.4.2', '>=')){
        Mage::getSingleton('eav/config')
        ->getAttribute('customer', 'rede_grupo')
        ->setData('used_in_forms',         array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register'))
        ->save();
    }

    $installer->endSetup(); 

This create in mage_core_resource the 'cadastros_setup' version 0.1.0 but not create the field.

What I'm doing wrong? Magento version: 1.8.1.0

1

1 Answers

0
votes

i have done one changes in config.xml

<global>
        <helpers>
          <cadastros>
            <class>Xkey_Cadastros_Helper</class>
          </cadastros>
        </helpers>
        <resources>
            <cadastros_setup>
                <setup>
                    <module>Xkey_Cadastros</module>
                    <class>Mage_Customer_Model_Entity_Setup</class>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </cadastros_setup>
            <cadastros_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </cadastros_write>
            <cadastros_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </cadastros_read>
        </resources>
    </global>