Categories


Archives


Recent Posts


Categories


Customer Confirmation

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

This one’s a little un-intuitive. At first.

There are times where you’ll want to programmatically check if a customer is confirmed. To do this you’d instantiate a customer object like this

$customer = Mage::getModel('customer/customer')->getCollection()
->addFieldToFilter('entity_id','197')
->getFirstItem();

or like this

$customer = Mage::getModel('customer/customer')->load(197);
$customer = Mage::getModel('customer/customer')->loadByEmail('foo@example.com');

However, if you dump out the data of a confirmed customer,

var_dump($customer->getData());
var_dump($customer->getConfirmation());
var_dump($customer->getData('confirmation'));

you won’t see a confirmation value. Maybe it’s EAV, so you add all the attributes to the select

$customer = Mage::getModel('customer/customer')->getCollection()
->addFieldToFilter('entity_id','197')
->addAttributeToSelect('*')
->getFirstItem();

Still Nothing. You might spent a lot of time cursing EAV and listeners, wondering where-the-heck the confirmation value is stored, and how-the-heck you’re supposed to load it from a customer object.

However, if you load a customer that hasn’t been confirmed and dump out the object’s data, you’re going to see something like this

  'confirmation' => string '700df1' (length=6)

which is a hint to what’s really going on.

There is a confirmation attribute associate with each object, but (in retrospect) it should have been named confirmation_key. Magento uses the attribute to store the key value that’s passed into the system when a customer click the confirmation link in their email.

That means if there’s a value in confirmation, then the customer is not confirmed, meaning if confirmation is empty then the customer is confirmed. The reason you don’t see any value in there for a confirmed customer is Magento removes the value after a customer is confirmed, so there’s nothing for EAV to load.

A little counter intuitive, but once you understand the intent of the attribute (store the confirmation key), it makes a lot more sense.

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 8th July 2011

email hidden; JavaScript is required