Comment 8 for bug 495381

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

Hello,

I'm not an Magento expert, but it seems to me that these codes may vary depending on configuration and modules installed on Magento. Someone can confirm / infirm that ?

You have to ensure that your configuration of Magento uses the same codes that the ones defined in the available_sort_by and default_sort_by fields of product.category.

To know them, you can display the source of the web page in the magento's administration where the fields are displayed (edit categories). In the source, check the value attribute of each option.

In our case, we have specific customizations on Magento so we anyway had to modify these codes.
You can put them in a configuration module just by overriding the columns, something like that :

class ProductCategory(magerp_osv.magerp_osv):
    """Modify the available magento sorting options."""
    _inherit = "product.category"

    SORT_BY_OPTIONS = (
        ('None', 'Use Config Settings'),
        ('position', 'Position'),
        ('price', 'Price'),
        ('custom_default_manufacturer', 'Manufacturer'),
        ('custom_rdc_availability', 'Availability'),
    )

    _columns = {
        'available_sort_by': fields.selection(
                            SORT_BY_OPTIONS,
                            'Available Product Listing (Sort By)',
                            size=32),
        'default_sort_by': fields.selection(
                            SORT_BY_OPTIONS,
                            'Default Product Listing Sort (Sort By)',
                            size=32),
    }

ProductCategory()

Regards
Guewen