How do I remove customers middle initial/name from the checkout page?

How the Magento 1.9.2.1 update affects Middle Name

First, the solution

I had the same issue when updating to Magento CE 1.9.2.1 from Magento CE 1.9.2.0. The update caused Middle Name to display, but when I checked the admin System > Configuration > Customers > Customer Configuration > Name and Address Options the "Show Middle Name (initial)" setting was already displaying "No" — which is what I wanted. I changed the setting to "Yes" and then back to "No" before clicking "Save Config", and this immediately removed Middle Name/Initial from Checkout when I refreshed the page.

The Database

In my case, I am working on updating a store from Magento 1.8.x to Magento 1.9.x. It is in my development environment that I updated from 1.9.2.0 to 1.9.2.1. In order to get the live site up-to-date when we launch the upgrade from 1.8.x to 1.9.x, we will need to update many of the admin settings, which we plan on doing directly in the database with a query. In the database, you can see how Magento changes the Middle Name setting.

The displayed Admin setting can be misleading

The table `core_config_data` handles the admin setting for "Show Middle Name (initial) with the record where `core_config_data`.`path`='customer/address/middlename_show'.

This record holds the setting in the `value` field (0="No", 1="Yes"). This field is not changed when the middle name appears by upgrading to Magento CE 1.9.2.1. If you save a change to the "Show Middle Name (initial)" in the admin settings after Magento makes changes during the update to 1.9.2.1, it will change the `core_config_data` value here.

The update to 1.9.2.1 did not change the record on `core_config_data`, and therefore what is displayed in the admin settings. But, the update does change a different record of a different table.

The actual middle name visibility is in `customer_eav_attribute`

In my many dev instances of Magento, the table `eav_attribute` has 2 "middle name" `attribute_code`(s), the `attribute_id`(s) being 6 and 21. The `customer_eav_attribute` table sets the visibility of the attribute with a field `is_visible`.

  • In my live 1.8.x environment, `attribute_id`(s) 6 and 21 had `is_visible` = 0.
  • After updating the dev to Magento CE 1.9.2.1 from Magento CE 1.9.2.0, it became `is_visible` = 1.
  • After I toggled and saved the admin "Show Middle Name (initial)" to "No", `is_visible`=0 again and the Middle Name/Initial field disappeared from Checkout.

Summary

The Magento CE 1.9.2.1 update flipped the Middle Name setting in the `customer_eav_attribute` table without affecting what is displayed in the Magento admin under the "Show Middle Name (Initial)" setting. You can fix it the way the setting is normally adjusted in the admin, without making far-reaching template adjustments, by toggling the "Show Middle Name (Initial)" setting.

Side note

If for some reason you need to transfer this admin setting across multiple copies of a store, or in a batch of admin updates, like while upgrading a store to match a dev environment... You can use the following SQL statement for this setting (provided you know that "middle name" is `attribute_id` 6 and 21 in your store. This is standard to Magento, but to be safe, double-check your `eav_attribute` table first.).

UPDATE customer_eav_attribute SET is_visible = 0 WHERE attribute_id IN (6, 21);


The technical answer

The system config option has got a backend model (Mage_Adminhtml_Model_System_Config_Backend_Customer_Show_Customer) whose _afterSave method makes the same change in the customer EAV attribute (table: customer_eav_attribute).

The system config option value and the EAV attribute is_visible value might not necessarily be in sync (either because of a Magento upgrade, or if the config option was changed programmatically, or any other reason).

Flipping the switch a couple of times will fix it, or, if you're like me and use install/upgrade scripts for everything, you can do the following :

Mage::getModel('core/config')
    ->saveConfig('customer/address/middlename_show', 0);    

try {

    $attribute = Mage::getSingleton('eav/config')
        ->getAttribute('customer', 'middlename')
        ->setIsVisible(0)
        ->save();

    $attribute = Mage::getSingleton('eav/config')
        ->getAttribute('customer_address', 'middlename')
        ->setIsVisible(0)
        ->save();

} catch (Exception $e) {
    Mage::logException($e);
    throw $e;
}

The easiest way:

Magento ver. 1.9.2.1

System > Configuration > Customers > Customer configuration > Name and Address Options

Show Middle Name (initial) = No

enter image description here