Is it possible to create a swatch attribute via the API endpoint? Swatch product attributes are seemingly created programatically by setting swatch_input_type data to the attribute, as demonstrated here:

From debugging, it seems this flag is then used to save swatch configuration data to the additional_data field in the catalog_eav_attribute table:

  "swatch_input_type": "visual",
  "update_product_preview_image": "0",
  "use_product_image_for_swatch": "0"

However, there seems to be no relative POST options for swatch_input_type in the swagger documentation of the product attribute endpoint - and also no way to set swatch configuration JSON to additional_data field of the catalog_eav_attribute table:

I can deduce that this is because there are no relative methods in the product attribute interfaces to get/set this data:

The closest I've been able to get to creating a swatch attribute via the API is by setting the following string to the frontend_input field in my request body:

"frontend_input": "swatch_visual"

This seems to create the attribute, but in a malformed state. Product swatch attributes should have a frontend_input type of "select". It seems Magento will actually reformat attributes with frontend_input type of "swatch_visual" but only when manually saved via the admin panel.


Your Answer

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

Browse other questions tagged or ask your own question.