0

I Have next question, i added attubute:

<?php
                    $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
                    $setup->addAttribute('customer', 'vat', array(
                    'label'     => 'VAT',
                    'type'      => 'varchar',
                    'input'     => 'text',
                    'visible'   => true,
                    'required'  => false,
                    'position'  => 1,
                    ));
                    $eavConfig = Mage::getSingleton('eav/config');
                    $attribute = $eavConfig->getAttribute('customer', 'vat');
                    $attribute->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit'));  //enable all action
                    $attribute->save();
                    ?>

now i need add condition: if the attribute is empty, print the value NO in vat field

how i can do this better? Thanks

1 Answer 1

0

You can get customer attribute value and check if empty like this ,

$customer_id = 2; // your customer id
$customerObj = Mage::getModel('customer/customer')->load($customer_id); 
$val = $customerObj->getData('vat');

if(empty($val)) {
//your stuff here
}
else {
//your stuff here
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.