Working with the Features of a Product

Product Features API

This guide demonstrates how to interact with product features using the Venddor API. Product features allow you to define specific characteristics of your products.

Note: Features are a powerful way to provide detailed product specifications that customers can use to filter and compare products.

Learn a Product's Features

To retrieve the features associated with a specific product, use the GET method with the product ID:

GET /products/{id}/features

Retrieves all features associated with the specified product.

Example Request

curl -X GET 'https://www.venddor.com.br/api/products/14/features'

This request returns all features for the product with product_id=14.

Create a Product with a Feature

When creating a new product, you can simultaneously define its features:

POST /products

Creates a new product with specified features.

Feature Type Example

This example demonstrates adding a text feature (type "T") with feature_id=23 to a new product:

curl --header 'Content-type: application/json' -X POST 'https://www.venddor.com.br/api/products' --data-binary '{
  "product": "New Product",
  "category_ids": "223",
  "main_category": "223",
  "price": "10",
  "status": "A",
  "product_features": {
    "23": {
      "feature_type": "T",
      "value": "Test"
    }
  }
}'

This request creates a new product with the text feature value set to "Test".

Successful Response

{
  "product_id": 250
}

Update a Product's Feature

To update an existing product's features, use the PUT method:

PUT /products/{id}

Updates the features of an existing product.

Example Request

curl --header 'Content-type: application/json' -X PUT 'https://www.venddor.com.br/api/products/250' --data-binary '{
  "product_features": {
    "23": {
      "feature_type": "T",
      "value": "Feature updated"
    }
  }
}'

This request updates the product with product_id=250, changing the value of the text feature with feature_id=23 to "Feature updated".

Successful Response

{
  "product_id": 250
}
Tip: When updating product features, you only need to include the features you want to modify. Other product data and features will remain unchanged.