Export product will lead to category assignment deletion when product is linked to several stores

Bug #1168362 reported by Robert Rübner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Magento OpenERP Connector
Confirmed
Undecided
Sébastien BEAU - http://www.akretion.com

Bug Description

Hi all,

- magentoerpconnect: revision 685 from oerp6.1-stable branch
- Magento: 1.6.0.0 using only simple products

I have products linked to 2 websites in Magento. I also have 2 root catgeories, one root category for one website / store the other root category for the other website / store. Products have category assignments in both root categories. I imported these products in OpenERP without problems, categories are correct assigned in OpenERP.
If I export products in OpenERP, e.g. via export product function in product detail view, I have to choose for what shop I want to start the export. Problem is now that only categories related to one shop will be used for the update on Magento side. These categories will replace the whole old product category assignment during the update process in Magento and so the categories of the other shop get lost.

To fix this problem I added the following function to class product_product in magentoerpconnect/product.py:

def _get_categories_ids_for_shop(self, cr, uid, product_id, shop_id, context=None):
        """
        For Magento: We have to export all assigned categories (shop independent).
        Otherwise we would delete category assignments during product export on
        Magento side when the product have category assignments in more than one
        root category. We can have several root categories for several stores.
        """
        product = self.read(cr, uid, product_id, ['categ_ids', 'categ_id'], context=context)
        product_categ_ids = set(product['categ_ids'])
        product_categ_ids.add(product['categ_id'][0])
        return product_categ_ids

Regards
Robert

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hello,

Thanks for your report and your solution.
That seems correct to me, but Sébastien can you confirm and merge in oerp6.1-stable please?
I'm not confident to merge that myself as I worked on the oerp6.1-oldstable and I'm currently working on the version 7, so I don't have the necessary knowledge on this branch.

Guewen

Changed in magentoerpconnect:
assignee: nobody → Sébastien BEAU - http://www.akretion.com (sebastien.beau)
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.