[TRUNK] available_sort_by bug/feature magento limitation

Bug #876312 reported by Sébastien BEAU - http://www.akretion.com on 2011-10-17
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Magento OpenERP Connector
Fix Committed
High
Alexandre Fayolle - camptocamp

Bug Description

Hi
On previous version the attributs available_sort_by was uncorrectly supported. Indeed the field available_sort_by was a many2one in openerp and a multiselect in magento. Now the field is a many2many in Openerp.
I just finish to refactor the code and and it's look like the syncronization openerp=>magento is still not correct.
Indeed if I push the value with the data None for available_sort_by (this is mean 'use default configuration') it's work perfectly.
But if I push with some option (for example : ['price', 'name']) Magento raise an error and tell us that the attributs available_sort_by is require. It's look like that with some version of magento the API have a bug.

I will try to spend more time to fix it but as the refactor doesn't introduce any regression, It not a priority for the moment.
Indeed tou can you syncronize still syncronize (as before) the category using the default configuration for default_sort_by and available_sort_by.
If it's really important for you to have this feature working perfectly, ask us.
Best regards

change done on trunk rev 469 and 470

Related branches

Changed in magentoerpconnect:
status: New → Confirmed
importance: Undecided → Low
Changed in magentoerpconnect:
assignee: nobody → Sébastien BEAU - http://www.akretion.com (sebastien.beau)

I'm affected by this bug and here is what I found while digging around.

1. It seems that the underlying magento bug is fixed in magento >= 1.4.2. Unfortunately, I'm stuck with 1.4.0.1.

2. People have found a local fix, eg on http://magja.googlecode.com/svn-history/r417/trunk/src/main/java/com/google/code/magja/model/category/Category.java, there is the following doc string for setAvailableSortBy

Run this SQL query first to fix the available_sort_by bug (tested with Magento 1.4)
            <code>update eav_attribute set is_required = 0 where attribute_code = 'available_sort_by';</code>
See:
           http://www.magentocommerce.com/bug-tracking/issue?issue=6842
           http://www.magentocommerce.com/boards/viewthread/48088/#t198697

3. if accessing the magento DB is not possible, then a safer way is to pass an empty string, which is processed by Magento as meaning "use all categories". This also works for the default_sort_by attribute (in which case Magento interprets this as 'use the parameters of the configuration'. In any case, passing the string "None" (which is the current behavior of the connector) is a bug. Empty string is what must be passed.

I just submitted a merge proposal fixing this issue.

Changed in magentoerpconnect:
status: Confirmed → In Progress
assignee: Sébastien BEAU - http://www.akretion.com (sebastien.beau) → Alexandre Fayolle @ camptocamp (alexandre-fayolle-c2c)
importance: Low → High
Changed in magentoerpconnect:
status: In Progress → Fix Committed
Paul Catinean (wiz-keed) wrote :

Thank you for your efforts but it is still not working and giving the Fault: <Fault 103: 'Default Product Listing Sort by not exists on Available Product Listing Sort By'> when i try to export catalog

Ubuntu 10.04
Openerp 6.1
Magento 1.7

Same problem here

Ubuntu 10.04
Openerp 6.1
Magento 1.7

exporting catalog causes Fault: <Fault 103: 'Default Product Listing Sort by not exists on Available Product Listing Sort By'>
and no category created in openerp gets exported to magento.

OK, I don't have a magento 1.7 instance available to make tests. From reading various magento forums, I thought the problem had been fixed in >= 1.5, so it seems it is not the case.

Can you check with branch https://code.launchpad.net/~magentoerpconnect-community/magentoerpconnect/openerp6.1-legacy-module-fix_available_sort_by_mag1.7 (you'll need to change the referential version and reload the mappings) and report back ?

using the branch https://code.launchpad.net/~magentoerpconnect-community/magentoerpconnect/openerp6.1-legacy-module-fix_available_sort_by_mag1.7 , after changing referential version to Magento Version 1.7.0.0+ and reloading the mappings, exporting the catalog still causes errors :

2012-07-20 07:59:56,942 6359 ERROR ? openerp.addons.base_external_referentials.external_osv: UPDATE ERROR: <Fault 103: 'Default Product Listing Sort by not exists on Available Product Listing Sort By'>
Traceback (most recent call last):
  File "/home/openerp/addons/magento/base_external_referentials/external_osv.py", line 933, in ext_update
    self.try_ext_update(cr, uid, data, conn, method, oe_id, external_id, ir_model_data_id, create_method, context)
  File "/home/openerp/addons/magento/magentoerpconnect/product.py", line 222, in try_ext_update
    return conn.call(method, [external_id, data])
  File "/home/openerp/addons/magento/magentoerpconnect/magerp_osv.py", line 106, in call
    res = self.ser.call(self.session, method, arguments)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
    return u.close()
  File "/usr/lib/python2.6/xmlrpclib.py", line 838, in close
    raise Fault(**self._stack[0])
Fault: <Fault 103: 'Default Product Listing Sort by not exists on Available Product Listing Sort By'>
2012-07-20 07:59:56,947 6359 INFO ? openerp.addons.base_external_referentials.external_osv: may be the resource doesn't exist any more in the external referential, trying to re-create a new one
2012-07-20 07:59:57,888 6359 ERROR ? openerp.addons.base_external_referentials.external_osv: Failed to Update in External Ref product.category from OpenERP with external_id 2 and OpenERP id 3

Paul Catinean (wiz-keed) wrote :

Upon further inspection and diggin, with the help of Guewen Baconnier i've noticed that the available_sort_by for product categories is an empty string when it should be a list with an empty string [''] and default_sort_by should be an empty string in this case ''. Furthermore if the value inside default_sort_by is not contained in the available_sort_by list it will error out once more, and there are a few more combinations that will also fail...

well at least in some way I got it working:
using openerp6.1-legacy-module, referential version to Magento Version 1.5.0.0+, (re)loading the mappings,
in Object Mapping of Product.Category, changing available_sort_by external type from String to List
and resyncronising referential settings
as long as in the product category "Display Settings" tab the "Use Default Config" checkbox for Available Sorting method is unchecked, and Default Sorting method is one of the methods in Available Sorting method list,
exports of products and categories works

OK, I discussed things with Guewen, and it seems that the suggestion of using [''] works with magento >= 1.5. So the latest head of the main branch should fix the issue for magento 1.5 and 1.7. You to get the head of lp:magentoerpconnect/openerp6.1-legacy-module, change your referential to 1.5.0.0+, reload the mapping, test and report back.

Hi,

I tested the export on a version 1.4.2 of Magento and I got the error again when available sort by is "Use Default Config" and default sort by is "Use Config Settings".
I just pushed a new revision which also use [''] for available sort by for the version 1.4.2 of magento.

Now it works when both options use the configuration settings.
But I'm not able to change the default sorting method to another option than "Use Config Settings" when available sorting method is "Use Default Config".
Example :
I export a category with
Available Sorting method: Use default config (so, all sort by methods)
Default Sorting method: Use Config Settings
=> OK (checkboxes are well updated on magento)

I export a category with
Available Sorting method: Use default config (so, all sort by methods)
Default Sorting method: Name
=> <Fault 1: 'Default Product Listing Sort by not exists on Available Product Listing Sort By'>

I export a category with
Available Sorting method: manually selected Name, Best Value, Price
Default Sorting method: Name
=> everything OK

I think that's a Magento bug because it have no reason to not accept the Name sorting method when I use default config for the available sorting method.

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

Other bug subscribers