2

The primary category of a product is present in the product document (primary_category_id) in the DATA API but cannot be written. After sending a PATCH update of the product with a different primary_category_id, it doesn't change.

Is there a way of doing this through the OCAPI?

martin
  • 247
  • 3
  • 15

2 Answers2

1

Can be some limitation for PATCH Method.Fields that can be updated: name, page_description, long_descripton, page_title, page_keywords, brand, ean, upc, manufacture_sku, manufacture_name, searchable, unit, searchable, online_flag, default_variant_id.

Try with PUT Method. PUT https://hostname:port/dw/data/v19_1/products/{id}. Also, please check Request Document.

Netinel
  • 101
  • 1
  • 2
  • I tested with PUT directly and POST + method override but it isn't still updating the primary_category_id. It does other custom fields, though. – martin Jan 12 '19 at 18:53
  • Also, I got the primary_category_id field in the GET response before but it doesn't seem to work now. – martin Jan 12 '19 at 18:53
0

At this time it does not appear that this is possible to manage via OCAPI.

I suspect that in the future you'd be able to achieve it using the following resources:

DELETE /catalogs/{catalog_id}/categories/{category_id}/products/{product_id}

followed by:

PUT /catalogs/{catalog_id}/categories/{category_id}/products/{product_id}

With a ProductCategoryAssignment document in the PUT call.

However, this would require that Salesforce adds those attributes to the ProductCategoryAssignment document.

The reason I suggest this is where it would be added is that within a catalog import document (XML) the flags are associated with a similar resource representation. eg:

    <category-assignment category-id="gear-bags-backpacks" product-id="NSF4003100">
        <primary-flag>true</primary-flag>
    </category-assignment>
sholsinger
  • 3,028
  • 2
  • 23
  • 40