Magento upgrade cannot save the customer, Unknown column ‘ca.sort_order’

magento-cannot-save-the-customer

First find out what cause the error.
“CANNOT SAVE THE CUSTOMER” is plain text message mask by magento to avoid it display raw message to system user. By find out raw, you are able to debug the error.

First, edit file: app/code/core/Mage/Customer/controllers/AccountController.php
In ubuntu, you can do like below: magento-cannot-save-the-customer-nano-acccontroller

Then, add $e->getMessage() to this line:

magento-cannot-save-the-customer-nano-acccontroller-egetmessage

Now, try create a customer account again, you will see raw error message like below:

magento-cannot-save-the-customer-e-getmessage

If you detailed it, it is the “ca.sort_order” was missing:

Cannot save the customer. 
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ca.sort_order' in 'order clause', query was: 
SELECT `main_table`.*, `ea`.`entity_type_id`, `ea`.`attribute_code`, `ea`.`attribute_model`, `ea`.`backend_model`, `ea`.`backend_type`, `ea`.`backend_table`, `
    ea`.`frontend_model`, `ea`.`frontend_input`, `ea`.`frontend_label`, `ea`.`frontend_class`, `ea`.`source_model`, `ea`.`is_required`, `ea`.`is_user_defined`, 
    `ea`.`default_value`, `ea`.`is_unique`, `ea`.`note`, `ca`.`is_visible`, `ca`.`is_visible_on_front`, `ca`.`input_filter`, `ca`.`lines_to_divide_multiline`, 
    `ca`.`min_text_length`, `ca`.`max_text_length`, `ca`.`data_model`, `sa`.`website_id` AS `scope_website_id`, 
    IF(sa.is_visible IS NULL, ca.is_visible, sa.is_visible) AS `scope_is_visible`, 
    IF(sa.is_required IS NULL, ea.is_required, sa.is_required) AS `scope_is_required`, 
    IF(sa.default_value IS NULL, ea.default_value, sa.default_value) AS `scope_default_value`, 
    IF(al.value IS NULL, ea.frontend_label, al.value) AS `store_label` 
FROM `customer_form_attribute` AS `main_table` 
INNER JOIN `eav_attribute` AS `ea` ON main_table.attribute_id = ea.attribute_id 
INNER JOIN `customer_eav_attribute` AS `ca` ON main_table.attribute_id = ca.attribute_id 
LEFT JOIN `customer_eav_attribute_website` AS `sa` ON sa.attribute_id = main_table.attribute_id AND sa.website_id = 1 
LEFT JOIN `eav_attribute_label` AS `al` ON al.attribute_id = main_table.attribute_id AND al.store_id = 1 
WHERE (attribute_code != 'created_at') 
AND (main_table.form_code = 'customer_account_create') 
AND (ea.entity_type_id = 1) 
ORDER BY ea.is_user_defined ASC, ca.sort_order ASC

Easiest way to fix this is by running Magento’s database repair tool which can be found at the following link:
http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/db-repair-tool

Database repair tools consist only one file – magento-db-repair-tool-1.2.php
For database repair tools to work, download, extract and put the php file in your site in any folder of that is accessible. It can be in your root www folder, so you may call it like this:

http://yoursite.com/magento-db-repair-tool-1.2.php

It should shows like below:
Fill in all necessary information and click continue.

magento-cannot-save-the-customer-before_repair

After the repair process run, you should see some result like below:
You can see it add missing field(s) such as the one missing that cause above error – “sort_order” to customer_eav_attribute.

magento-cannot-save-the-customer-after_repair

Hope this help some one out there having same problem.

By Keenlio, January 28, 2015

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


9 + = fifteen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>