Open
Conversation
hbrunn
requested changes
Sep 29, 2016
magentoerpconnect/product.py
Outdated
| if main_categ_id: | ||
| if self.backend_record.categ_id.id not in category_ids): | ||
| result['categ_id'] = main_categ_id | ||
| else: |
Member
There was a problem hiding this comment.
why would you need this? This branch causes the value to be overwritten with itself
magentoerpconnect/product.py
Outdated
| # skip main cat assignment if the current main category is already in | ||
| # categ_ids | ||
| if main_categ_id: | ||
| if self.backend_record.categ_id.id not in category_ids): |
current category in odoo is one of the categories fetched from magento.
1d9eadc to
e6cf79f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When fetching categories from magento the connector returns a list of category ids.
To decide which one will be updated as categ_id (main category) the connector pops the last element of the categories and elects it as the main category of the product.
This randomness may cause unpredictable behaviour on update when using multiple categories in magento.
We had a client who wanted some products to be category: product_price/ 6 and product_price 5.
when updating products the connector would substitute some of the categories of some products and leave other intact. (depending on wich category happened to be the last in the magento category list.)
We are adding a little bit more logic to this decision. If the current main category of the odoo product exists already in the list of returned categories from magento, do not update the main category at all.