Magento Enterprise API – How to Update Category

apimagento-enterprise

When I am trying to update a category through API I get Fatal error: Uncaught SoapFault exception: [103] Default Product Listing Sort by does not exist in Available Product Listing Sort By.
My call is:

$catResult = $proxy->call($session, 'catalog_category.update', array(181, array(
                'is_anchor' => 1,
                'include_in_menu' => 0,
                'available_sort_by' => "",
                'default_sort_by' => "",
            )));

I searched but I couldn't find anything that could fix this issue. I saw that at some point it is was a reported bug…but it should be fix by now.
Does anyone know what is the problem? I want that my category to have default settings set.

Best Answer

The error indicates that the value for the default_sort_by field is invalid, because you use a empty value. Depending on the field that you want to use for sorting you need to enter it here, for example you could use position:

$result = $client->call($session, 'catalog_category.update', array(181, array(
                'is_anchor' => 1,
                'include_in_menu' => 0,
                'available_sort_by' => "position",
                'default_sort_by' => "position",
            )));

The code above should work, other options that are there by default are 'name' and 'price'. If you want another attribute to use as sortable field, you can set the option 'Used for Sorting in Product Listing' to 'Yes' for the attribute thru that admin option Catalog => Attributes => Manage Attributes