2

I've followed this answer@stackexchange to create a new attribute (called mobile) for the customer entity.

I was able to create an input field in the registration form(customer_account_create) and able to save the entered value in customer_entity_varchar table associated with the attribute_id (mobile)

Now, I wanted like to make this attribute unique i.e no user can register for another account using same mobile number. To achieve this, I modified the msql4-install-0.1.0.php file at (app/code/local/MyCompany/MyModule/sql/customerattribute_setup/...php)

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

$installer->addAttribute("customer", "mobile",  array(
    ....
    "unique"     => true,
    ...

    ));

By changing the property from false to true. The new customer attribute has is_unique=1 in the eav_attribute table.

However, the unique constrain does not apply for some reason when I try to create a new user from the registration form using different email ID but same mobile number (associated to attribute - mobile).

Do I have to do something else so that I can allow users creation only if the said attribute is not associated to any other user ??

1

The customer attributes has no is_unique option which is available for product attributes

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.