Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

Username import problem #27

Open
sylvainraye opened this issue May 12, 2016 · 1 comment
Open

Username import problem #27

sylvainraye opened this issue May 12, 2016 · 1 comment
Labels

Comments

@sylvainraye
Copy link
Collaborator

Hello again -

Just adding on here - another issue (not as big a deal as the import - I had to manually input those) - when editing an order in the admin, as you know magento deletes and recreates the order - well, when it goes to create the order, it throws a "username already exists" error and doesn't create the order from the admin. The username field is editable on the form and populated - when I remove the entry from the text box, the order creates fine - just wanted to let you know about the error....

Hope you are well -
Larry

Hi Sylvain -

I did look in the database last night to make sure the attribute existed - I'll check those rows. But the username works on the site when I log in, and it exports with the other customer data as well. I exported the customers first to get the appropriate header value from the csv file so that I knew what to use when I imported (it is "username" - no underscores). All of my test customers exported with populated usernames just fine.

Ok - I pulled those rows out of the database:

INSERT INTO eav_attribute (attribute_id, entity_type_id, attribute_code, attribute_model, backend_model, backend_type, backend_table, frontend_model, frontend_input, frontend_label, frontend_class, source_model, is_required, is_user_defined, default_value, is_unique, note) VALUES
(153, 1, 'username', NULL, NULL, 'varchar', NULL, NULL, 'text', 'Username', NULL, NULL, 0, 1, NULL, 0, NULL);

INSERT INTO customer_eav_attribute (attribute_id, is_visible, input_filter, multiline_count, validate_rules, is_system, sort_order, data_model) VALUES
(153, 1, NULL, 0, 'a:2:{s:15:"max_text_length";i:30;s:15:"min_text_length";i:6;}', 1, 44, NULL);

I did read a couple of things yesterday that might offer insight:

http://mageinn.com/fatal-error-call-to-a-member-function-getbackendmodel-on-a-non-object-during-customer-import/
http://magento-quickies.alanstorm.com/post/91985359245/call-to-a-member-function-getbackend-on-a

@sylvainraye
Copy link
Collaborator Author

PHP Fatal error: Call to a member function getBackendModel() on a non-object in /app/code/community/Diglin/Username/Model/Import/Entity/Customer.php on line 83

That error on the import is related to the username - when its looping through the attributes, it does firstname fine, lastname fine , and then gets to username and bombs - that error in the logs is a result of the attribute being null:


app/code/community/Diglin/Username/Model/Import/Entity/Customer.php

$attribute = $resource->getAttribute($attrCode); <<<null is returned here
$backModel = $attribute->getBackendModel(); <<<<< the error in the logs


The problem - when the customer model loads attributes - this following function is returning NULL to the above when it gets to "username" - so then the getBackendModel error is thrown - $attribute isn't an object for username. It is for the other attributes that load prior -so its working until then:


Mage/Customer/Model/Customer.php

/**

  • Get customer attribute model object
  • @param string $attributeCode
  • @return Mage_Customer_Model_Entity_Attribute | null
    _/
    public function getAttribute($attributeCode)
    {
    $this->getAttributes();
    if (isset($this->_attributes[$attributeCode])) {
    return $this->attributes[$attributeCode];
    }
    return null;
    }
    *
    ***********************************************************************************

So when importing this function is returning null for username instead of a Mage_Customer_Model_Entity_Attribute object - I'm using the import->import function - should i be using import -> dataflow for the tool instead?

@sylvainraye sylvainraye added the bug label Jul 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

1 participant