Question

As store owner, the two name field data (First name and last name) is very inconvenience while running store.

  • Most of shipping carrier I use ask only one full name data when I import shipping address. I have to merge both first and last name data as one after export shipping address. (Even a payment company ask only one full name data)

  • It cause some issue when I manage or search customers with name

  • I tired to get only one name data, but I got problems since magento use first name and last name differently on many ways (even in welcome message) so I give up

  • As customer's view, it looks inconvenience too. Type first name and click other field and type last name instead of just type full name. (checkout is important since its related conversion rate)

I hope Magento get only one name data as store owner (I believe Magento is made for store owner too)

Can I know at least the reason why Magento ask two name field as developer's view? Is there any benefit?

e.g.) Top e-commerce company Amazon and ebay ask only one

This is Amazon New address form - Only one name field

enter image description here

eBay New address form - only one name field

enter image description here

Was it helpful?

Solution

It's just part of Magento's architecture to use a first name and a last name.

Your question asks why this is the case. Presumably, Magento has added the firstname and lastname attributes (along with even an optional middlename one is defined as default but not displayed) to provide as much flexibility as possible for the merchant. This is a departure from other more established sites, as you noted, but Magento has to cater for a range of possible merchants, and tries to be as non-specific as possible.

However, like all of Magento, nothing is set in stone, and it can be changed, however this is a coding exercise, and as a result can be quite a complicated procedure. To enable this, you'd need to do a few different things. I'll try and detail the steps I'd take below.

1. Add Full Name Attribute

The full name needs to be added as an attribute to a customer. You can create a module to handle this, but essentially, you'll need to run an installer script to install fullname as an attribute against the customer attribute set.
There are lots of useful tutorials about this around the web. Excellence Magento has a great one (code partially shown below, edited to your requirements)

$setup->addAttribute('customer', 'fullname', array(
    'type' => 'text',
    'input' => 'text',
    'label' => 'Full Name',
    'global' => 1,
    'visible' => 1,
    'required' => 1,
    'user_defined' => 1,
    'default' => '0',
    'visible_on_front' => 1
));

2. Add your new attribute in your templates

You'd now need to go through and add the field for your new attribute to all relevant templates; thereby allowing the user input of it.

You can remove the First Name and Last Name fields in the process, wherever they are applicable.

3. Adjust the firstname and lastname attributes

First Name and Last Name are required attributes in the database, so you won't be able to do much until you remove their required status from the attributes themselves.

You'll need to write a single-use script to adjust the settings; the code should resemble the following:

$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('customer','firstname');
if ($attributeId) {
    $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
    $attribute->setIsRequired(false)->save();
}

$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('customer','lastname');
if ($attributeId) {
    $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
    $attribute->setIsRequired(false)->save();
}

After that, you should have successfully transferred firstname and lastname into a single fullname field.

If you have any existing customers, you'll be able to write a script that will combine the firstname and lastname fields into the fullname one.

OTHER TIPS

Simple it depends on the Magento architecture. Where Magento store "first name " or "last name" as an attribute and also "middle name" which is rarely used by the peoples.

I'm not sure why are you having this scenario.
Magento has a $customer->getName() function for customer object which will always return complete name.
You just need to use getName() rather than getfullName() or getData('fullname').

I hope this will solve all your concerns. :)

Can I know at least the reason why Magento ask two name field as developer's view? Is there any benefit?

You can create fullname from first_name and last_name and you can use them separately as well but if you only have a single field for name, You can't do that. Like for frontend rendering, I would like to get greeting as Hello Aman rather than Hello Aman Srivastava.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top