1

I have enabled the middle name feature of Magento and it works perfectly for the complete shipping/invoice address fields, however, in the Admin interface, things like the "Bill To Name", "Ship to name", invoice names, etc are all without the middle name. I'd like to have the middle name in it, mostly because in the (default) mailtemplates the references are to that name.

For instance, when I sent out the confirmation e-mail, the shipping address has the correct name "Hendrik van Dijk", but the mail starts with "Dear Hendrik Dijk". I may be able to fix this by changing the templates, but I think it's cleaner and better to correct it so it also shows correctly in the backend.

Someone knows how to do this?

1

For Grids please try to change app/code/core/Mage/Sales/Model/Resource/Order.php -> protected function _initVirtualGridColumns() as you add this code:

$ifnullMiddle    = $adapter->getIfNullSql('{{table}}.middlename', $adapter->quote(''));

bellow:

$ifnullFirst   = $adapter->getIfNullSql('{{table}}.firstname', $adapter->quote(''));

and replace this:

$concatAddress = $adapter->getConcatSql(array($ifnullFirst, $adapter->quote(' '), $ifnullLast));

with this:

$concatAddress = $adapter->getConcatSql(array($ifnullFirst, $adapter->quote(' '), $ifnullMiddle, $adapter->quote(' '), $ifnullLast));

You also have to change app/code/core/Mage/Sales/Model/Resource/Order/Creditmemo.php and app/code/core/Mage/Sales/Model/Resource/Order/Invoice.php which are almost the same as Order.php. Please keep in mind that most probably this will work only on new orders (because tables sales_flat_..._grid are already generated for the old orders).

For "Dear, Customer Name" please try to change app/code/core/Mage/Sales/Model/Order.php -> public function getCustomerName() as you replace this:

$customerName = $this->getCustomerFirstname() . ' ' . $this->getCustomerLastname();

with this:

$customerName = $this->getCustomerFirstname() . ' ' . $this->getCustomerMiddlename() . ' ' . $this->getCustomerLastname();

It's recommended to make your own module which rewrites these classes or at least copy these files to app/code/local and then to modify them.

| improve this answer | |
  • Thanks for this solution - I knew that programatically it should normally be able to solve this, but in my opinion it's stupid that there is an option for middlename that is not implemented in a consequent manner. – Calypso971 Dec 31 '14 at 13:49
  • Yes, they missed this. It happens. :) – michael Dec 31 '14 at 15:46

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.