I am trying to set the manufacturer for import logic (REST API) and I have the manufacturer name. However the API is expecting an int for the manufacturer attribute.

Is there a way to programmatically set the manufacturer per product or first set/get the manufacturers and then use their IDs for the REST product set?

The error I get:

{"message":"Error occurred during \"custom_attributes\" processing. Attribute \"manufacturer\" has invalid value. Invalid type for value: \"A manufacturer name\". Expected Type: \"int\"."}

You need to use the catalogProductAttributeOptionManagementV1 API (http://devdocs.magento.com/swagger/) to get the product option value IDs, and then send these IDs as the custom attribute value.

For example:

GET /rest/V1/products/attributes/manufacturer/options

Might return:

    "label": " ",
    "value": ""
    "label": "Apple",
    "value": "1"
    "label": "Google",
    "value": "2"
    "label": "Microsoft",
    "value": "3"

You can then use these values in your next PUT/POST requests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.