ajayz15 / magja

Automatically exported from code.google.com/p/magja
1 stars 0 forks source link

Can not create new Customer #60

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using latest code of magja. and want to create new customer using it.
I'm able to get list of customers, products etc. But can't create new customer. 
It shows me this error.

=============Create New User=====================
Creating: [{middlename=midmidName, email=myemail@gmail.com, 
password_hash=098f6bcd4621d373cade4e832627b4f6, group_id=1, gender=1, 
lastname=lalastName, firstname=NewFirst, website_id=1}]

Error :
com.google.code.magja.service.ServiceException: Customer email is required

Original issue reported on code.google.com by sjk.fril...@gmail.com on 6 Feb 2013 at 8:35

GoogleCodeExporter commented 9 years ago
Hey.

We have been recently struggled with the same issue like yours.

The problem probably is a version mismatch between the Magja and the used 
Magento version. This assumption is based on that Magento 1.7 requires a 
different request then the API provides.

Please see this example:

 - Magja builds request:

=============Create New User=====================
Mage_Customer_Model_Customer Object
(
    [_eventPrefix:protected] => customer
    [_eventObject:protected] => customer
    [_errors:protected] => Array
        (
        )

    [_attributes:protected] => 
    [_addresses:protected] => 
    [_addressesCollection:protected] => 
    [_isDeleteable:protected] => 1
    [_isReadonly:protected] => 
    [_resourceName:protected] => customer/customer
    [_resource:protected] => 
    [_resourceCollectionName:protected] => customer/customer_collection
    [_cacheTag:protected] => 
    [_dataSaveAllowed:protected] => 1
    [_isObjectNew:protected] => 1
    [_data:protected] => Array
        (
            [0] => Array
                (
                    [email] => asdf@asdf.com
                    [password_hash] => b8e065255d5326ea3cf1f85b0dd764f3
                    [prefix] => ALC-000000001
                    [dob] => 1980-08-17 20:53:04
                    [e-mail] => asdf2@asdf.com
                    [group_id] => 1
                    [gender] => 1
                    [store_id] => 1
                    [lastname] => Tóth
                    [firstname] => János
                    [website_id] => 1
                )

            [store_id] => 0
            [group_id] => 1
            [entity_type_id] => 1
            [parent_id] => 0
            [created_at] => 2013-07-30 08:49:22
            [updated_at] => 2013-07-30 08:49:22
            [created_in] => Admin
            [website_id] => 0
            [disable_auto_group_change] => 0
        )

    [_hasDataChanges:protected] => 1
    [_origData:protected] => 
    [_idFieldName:protected] => entity_id
    [_isDeleted:protected] => 
    [_oldFieldsMap:protected] => Array
        (
        )

    [_syncFieldsMap:protected] => Array
        (
        )

)
=============/Create New User=====================

 - ... but the request should be like this:
=============Create New User=====================
Mage_Customer_Model_Customer Object
(
    [_eventPrefix:protected] => customer
    [_eventObject:protected] => customer
    [_errors:protected] => Array
        (
        )

    [_attributes:protected] => 
    [_addresses:protected] => 
    [_addressesCollection:protected] => 
    [_isDeleteable:protected] => 1
    [_isReadonly:protected] => 
    [_resourceName:protected] => customer/customer
    [_resource:protected] => 
    [_resourceCollectionName:protected] => customer/customer_collection
    [_cacheTag:protected] => 
    [_dataSaveAllowed:protected] => 1
    [_isObjectNew:protected] => 1
    [_data:protected] => Array
        (
            [email] => jancsi@toth.hu
            [password_hash] => b8e065255d5326ea3cf1f85b0dd764f3
            [prefix] => ALC-000000001
            [dob] => 1980-08-17 20:53:04
            [group_id] => 1
            [gender] => 1
            [store_id] => 1
            [lastname] => Tóth2
            [firstname] => János2
            [website_id] => 1
            [entity_type_id] => 1
            [parent_id] => 0
            [created_at] => 2013-07-30 09:33:27
            [updated_at] => 2013-07-30 09:33:27
            [created_in] => English
            [disable_auto_group_change] => 0
            [dob_is_formated] => 1
        )

    [_hasDataChanges:protected] => 1
    [_origData:protected] => 
    [_idFieldName:protected] => entity_id
    [_isDeleted:protected] => 
    [_oldFieldsMap:protected] => Array
        (
        )

    [_syncFieldsMap:protected] => Array
        (
        )

)
=============/Create New User=====================

 - Please note that the difference between the two requests is that some portion of the request (the entity itself) structured differently.

The solution is to modify the "serializeToApi" methods to your needs. For 
instance simply return with the Map<String, Object> rather then the 
List<Object>.

Hope it helps to anybody.

Original comment by torok.ka...@gmail.com on 30 Jul 2013 at 10:08