Enable fields in customer / account / create by means of code

0

I'm developing a module where it will change the value of the field Display Data de Nascimento and Ver CPF/CNPJ to Configurações> clientes> Configurações> nome e opções de endereço .

When this value is set as needed, it shows fields in the client registry in customer/account/create , so I use the following code in an installation script, so that when the module is activated already enable those fields that do not come by default.

code:

$inchooSwitch = new Mage_Core_Model_Config();

$inchooSwitch->saveConfig('customer/address/dob_show', "req", 'default', '');
$inchooSwitch->saveConfig('customer/address/taxvat_show', "req", 'default', '');

Successful code changes, but the fields when I access the cliente/conta/criar/ page do not appear.

Any idea why this happens?

    
asked by anonymous 01.04.2014 / 22:15

1 answer

0

I found the solution seeing system.xml they used a backend_model adminhtml/system_config_backend_customer_show_customer , which had the function _afterSave that defines the attribute as visible and Required, it follows the complete code after the adjustments:

<?php

Mage::getModel('core/config')->saveConfig('customer/address/dob_show', 'req');
Mage::getModel('core/config')->saveConfig('customer/address/taxvat_show', 'req');
Mage::getModel('core/config')->saveConfig('customer/address/gender_show', 'req');

$dobAtribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer', 'dob');
$dobAtribute->setData('is_required', 1);
$dobAtribute->setData('is_visible', 1);
$dobAtribute->save();

$taxvatAtribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer', 'taxvat');
$taxvatAtribute->setData('is_required', 1);
$taxvatAtribute->setData('is_visible', 1);
$taxvatAtribute->save();

$genderAtribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer', 'gender');
$genderAtribute->setData('is_required', 1);
$genderAtribute->setData('is_visible', 1);
$genderAtribute->save();
    
02.04.2014 / 21:18