Comment 13 for bug 688225

Revision history for this message
Raphaƫl Valyi - http://www.akretion.com (rvalyi) wrote : Re: [Bug 688225] Re: Importing products skip if catalog_product_entity = sku crisscross

Hello Kyle,

Actually, I'll test again before committing, but so far it works, here is
what I did:
patch your base_external_referentials/external_osv.py,
in method "oeid_to_extid" around line 46,
just before the line:
                    result = self.get_external_data(cr, uid,
self.external_connection(cr, uid,
self.pool.get('external.referential').browse(cr, uid,
external_referential_id)), external_referential_id, {}, {'id':id})
add:
                    if context.get('alternative_key', False):
                        id = context.get('alternative_key', False)
                    result = self.get_external_data(cr, uid,
self.external_connection(cr, uid,
self.pool.get('external.referential').browse(cr, uid,
external_referential_id)), external_referential_id, {}, {'id':id})

Admittedly, this is a bit hugly to patch an abstract module just because of
Magento, but it's really the simpler, so so far...
Then we also need to change the product mapping in order to tel we want to
use that 'alternative_key'.
So in OpenERP client, edit the instance 'sale.order.line' mapping, then edit
the product_id field mapping and add the following right at the beginning of
the mapping:
context['alternative_key'] = data['sku']

Try to import again, this will do the job and force OpenERP to lookup
Magento products by sku when importing order. Luckily enough, after import,
we properly continue to read the product_id field in the Magento answer and
we continue to use that product_id key as the cross reference in OpenERP.

Can you confirm it works for you too? BTW, Olivier Dony from OpenERP SA
pointed me to the following link on Twitter
http://www.fontis.com.au/blog/magento/api-product-ids-vs-skus
it seems it's a know issue. I can't believe they did that. I implemented
myself a polyvalent database id / absolute string id lookup on the OOOR
OpenERP Ruby connector, but at least I test the nature of the field before
doing anything wrong silently. They are really kidding.

Thank you to provide feedback, I'll probably commit Sunday or Monday.

On Sat, Dec 11, 2010 at 10:24 PM, Kyle Waid <email address hidden>wrote:

> Hi,
>
> We do not have a final database yet so we could just start over
> importing the products and then the sales orders. Would definitely like
> to try anything you have that could work. What we were going to do is
> change all of the effected products skus temporarily, import the
> products, then change them back and import orders. We tested that a
> little and it seems to work but that would be several hours worth of
> work.
>
> Please let me know if you would share any fixes. Thanks again for your
> time.
>
> --
> You received this bug notification because you are subscribed to Magento
> Open ERP Connector.
> https://bugs.launchpad.net/bugs/688225
>
> Title:
> Importing products skip if catalog_product_entity = sku crisscross
>
> Status in Magento Open ERP Connector:
> Confirmed
>
> Bug description:
> When we were importing our orders about 500 of our products would not
> import. We couldnt figure out why. We downloaded what we could and dumped it
> to a log file
>
> We discovered that when magento was returning the products OpenERP would
> not add the product to the database if the catalog_entity matched the sku.
> We are not sure why it happens
>
> Is there any way to fix this?
>
>
>