Products import does not match categories - Openerp6-module

Bug #711702 reported by Hillebrand Dalstra on 2011-02-02
This bug affects 10 people
Affects Status Importance Assigned to Milestone
Magento OpenERP Connector

Bug Description

During the installation of the Openerp6-module and all it dependencies, two default product categories are created (Service and All Products).
When configuring the settings of the connector a default category is required to be set in the Core Settings. I created a new default category called "Products without category" and set up the connector.

These are the steps:

1. Reload referential map settings
2. Synchronize Referential settings

Then I use the buttons in the connector in the presented sequence.

1) import Customer Groups
2) import product categories
3) import product attributes sets
4) import attribute groups
5) import product attributes
6) import products

Everything seems to be imported without a problem.

Except I have two problems:

First issue:

Something strange occurs when the product categories from Magento are imported. The "Root Catalog" suddenly gets a new parent category called "UNDEFINED".

Magento's original categories:

Root Catalog/
Root Catalog/CategoryX
Root Catalog/CategoryY

OpenERP imported catalog

UNDEFINED/Root Catalog/
UNDEFINED/Root Catalog/CategoryX
UNDEFINED/Root Catalog/CategoryY

Second issue:

The next problem occurs when all products from magento are imported to the 'All products" category and not in the category structure that was imported from Magento.
Manual assigning product categories in the 'Extra Categories tab" and exporting the catalog to Magento doesn't work neither.

I'm using the following setup:

- Openerp-server-6.0.0-rc2

- Openerp6-module ref. version: 381

Openerp6-module dependencies (extra-trunk ref. version:5158)
- Product_m2mcategories
- Base_sale_multichannels
- Base_external_referentials
- Product_images_olbs

- Magento with magento-module ref. version 24.

A similar question was posted here:

Any help would be greatly appreciated.


photo7 (photo7) wrote :

I found solution for this problem.

Sometimes during Magento development - Magento team renamed the "category_ids" attribute in Magento product object to just simple "categories". So we just need to change external mapping for this connector to reflect that.

This can be done very easy by editing the object mapping for product object on Magento instance configuration page. Just find the "category_ids" and and change it name to "categories", plus replace the "category_ids" with "categories" in export mapping Python code too (at the bottom in result list).

I also made the patch file for external mapping file.

This doesn't fix the "UNDEFINED" category name on initial import, but this is because Magento root category has parent = 0 and import mapping code define it is "UNDEFINED". Definitely can be better, but this doesn't create a problem really , as you can rename and reattach the "UNDEFINED" category after the import.


photo7 (photo7) wrote :

Applied the patch and I can confirm that I solution provided by photo7 works!
Thank you for solving this quickly.
I guess a new referential type needs to be included for magento

dao777 (dylan-oliver) wrote :

This patch worked for me, too - thanks!

Note to other OpenERP noobs - after editing the field mappings in the GTK interface, you have to click "save and close" on not only the "Mapping Lines" window but also the "Mappings" window and finally click 'save' on the whole 'Magento Instances' record. Once this was done, I was able to use the "Import Products" button to successfully resync products + their categories from Magento - no need to start all over.

Changed in magentoerpconnect:
status: New → Confirmed
importance: Undecided → High

the provided patch works, the question is whether we apply it or not. applying it would impact former versions of the connector that do not have this issue and as some said, I'm not sure we need to define a new mapping file just for that. At least, for the moment raising the priority of the bug will increase the visibility of the patch.

picou (6-contact-pointpc-net) wrote :

Could someone explain how to apply this type of patch in a V6 ? One other question in the same line; if an update with corections is on bazaar, how does one upply such an upgrade. (just preparing the future upgrade)

Did you select a warehouse before exporting ?

I still have the 'export problem' .

solved, just use client GTK

Fix in trunk version rev 465. (We change the way to store mapping for trunk version so it will be easier to manage various mapping version ;) )
Thanks all for participating to our project.

Changed in magentoerpconnect:
status: Confirmed → Fix Released
Changed in magentoerpconnect:
status: Fix Released → Confirmed

This bug has been fixed only for magento 1.5.

I happens too in version 1.4.2+

That somewhat disappointed be because, some magento version accepted category_ids and some accepted categories.

So I wrote a little method which check on both methods 'ol_catalog_product.update' and 'catalog_product.update' whether categories / category_ids fields are updated.

I attach a worksheet with the method and the results.

It appears that Magento accepts both categories and category_ids.
Magento 1.4.2 and 1.5.0 accept only categories.

Magento has probably changed the name of the field in the version, can someone confirm that ?

I did not tested on versions < 1.4 or > 1.5, but I assume that versions < 1.4.2 use the category_ids fields while the versions >= 1.4.2 use the categories field.

So, I will do the changes on the mappings files for the version upper and equal to 1.4.2.

test_update(m1401, 1, [4,5])
# => Calling catalog_product.update on 1 with category_ids = [4]
# => OK
# => Calling catalog_product.update on 1 with categories = [5]
# => OK
# => Calling ol_catalog_product.update on 1 with category_ids = [4]
# => OK
# => Calling ol_catalog_product.update on 1 with categories = [5]
# => OK

test_update(m142, 77, [23, 24])
# => Calling catalog_product.update on 77 with category_ids = [23]
# => NOK
# => Calling catalog_product.update on 77 with categories = [23]
# => OK
# => Calling ol_catalog_product.update on 77 with category_ids = [24]
# => NOK
# => Calling ol_catalog_product.update on 77 with categories = [24]
# => OK

test_update(m151, 3, [4, 5])
# => Calling catalog_product.update on 3 with category_ids = [4]
# => NOK
# => Calling catalog_product.update on 3 with categories = [4]
# => OK
# => Calling ol_catalog_product.update on 3 with category_ids = [5]
# => NOK
# => Calling ol_catalog_product.update on 3 with categories = [5]
# => OK

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Related questions