0

How to load a customer with an eav attribute ?

I created a new eav attribute with that :

$attribute  = array(
        'type'          => 'varchar',
        'input'         => 'text',
        'label'         => 'My Field',
        'global'        => true,
        'visible'       => true,
        'default'       => '',
        'required'      => false,
        'user_defined'  => 0,
        'used_in_forms' => array(
                'adminhtml_customer',
        ),
);
$installer->addAttribute('customer', 'my_field', $attribute);

And now, I want to load customer, but the following code doesn't work :

$customer = Mage::getModel('customer/customer');
$customer->load($myField, 'my_field');

But if I load the customer with email (for example), after, I can get 'my_field' value with :

$customer->getData('my_field');

Any idea ?

0

Try to use This

$result = Mage::getModel('customer/customer')
              ->getCollection()
              ->addAttributeToSelect('my_field')
              ->addAttributeToFilter('my_field',$myFieldValue)->load();

if (is_object($result)) {
    /* Logic */
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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