3

I have migrated a site from 1.9.3.2 to 2.1.4 and there is a customer attribute customerno that was added from a module called Fontis_Customer. The old module has a file:

app/code/local/Fontis/Customer/Model/Entity/Setup.php

class Fontis_Customer_Model_Entity_Setup extends Mage_Customer_Model_Entity_Setup
{
        'customerno' => array(
                'label'         => 'Customer Number',
                'visible'       => true,
                'required'      => true,
        ),
}

After migration it carried this attribute over and is preventing checkouts. When I click the button to checkout I get the error message The value of attribute "customerno" must be set I ran a query:

mysql> select * from eav_attribute ea INNER JOIN customer_eav_attribute cea ON cea.attribute_id = ea.attribute_id WHERE ea.frontend_label LIKE '%Customer%' \G
*************************** 1. row ***************************
         attribute_id: 140
       entity_type_id: 1
       attribute_code: customerno
      attribute_model: NULL
        backend_model: NULL
         backend_type: varchar
        backend_table: NULL
       frontend_model: NULL
       frontend_input: text
       frontend_label: Customer Number
       frontend_class: NULL
         source_model: NULL
          is_required: 0
      is_user_defined: 0
        default_value: NULL
            is_unique: 0
                 note: NULL
         attribute_id: 140
           is_visible: 1
         input_filter: NULL
      multiline_count: 1
       validate_rules: NULL
            is_system: 0
           sort_order: 0
           data_model: NULL
      is_used_in_grid: 0
   is_visible_in_grid: 0
is_filterable_in_grid: 0
is_searchable_in_grid: 0

and I saw that the field is_required was set to 1. I set it to 0 thinking that would solve the problem but it doesn't. Is there somewhere else that this value is set to required in the database?

EDIT: I should note that I would prefer to do it at the database level instead of creating a module to do it for me.

1

Take a look : vendor/magento/module-eav/Model/Entity/Attribute/Backend/AbstractBackend.php::validate()

if ($attribute->getIsVisible()
    && $attribute->getIsRequired()
    && $attribute->isValueEmpty($value)
    && $attribute->isValueEmpty($attribute->getDefaultValue())
 ) {
       throw new LocalizedException(__('The value of attribute "%1" must be set', $attrCode));
 }

As we can see, this message occurs when: (using and conditions)

  • is_visible set to 1.
  • is_required set to 1.
  • This attribute has no value.

In your case, after changing is_required to 0, the checkout process should works. Should try again with:

  • Try to re-index database again.

  • Clear Magento Cache.

  • 1
    Clearing the cache and re-indexing did the trick! thanks – Yamaha32088 Mar 12 '17 at 4:47

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.