Actions72
- Bài Viết Actions
- Blog Actions
- Bộ Sưu Tập Actions
- Khách Hàng Actions
- Đơn Hàng Actions
- Trang Actions
- Sản Phẩm Actions
- Biến Thể Sản Phẩm Actions
Biến Thể Sản Phẩm → Tạo Mới
AI-generatedOverview
This node manages custom metafields on various Sapo resources, allowing users to create, retrieve, update, delete, count, and validate metafields associated with different resource types such as products, variants, customers, orders, etc.
For the "Biến Thể Sản Phẩm" (Product Variant) resource with the "Tạo Mới" (Create) operation, the node creates a new custom metafield for a specific product variant identified by its resource ID. This is useful when you want to add additional metadata or custom fields to product variants in your Sapo store, such as warehouse location, special attributes, or other custom data not covered by default fields.
Practical examples:
- Adding a storage location identifier to each product variant.
- Storing supplier-specific information or batch numbers as metafields.
- Attaching custom flags or tags to variants for internal processing.
Properties
| Name | Meaning |
|---|---|
| ID Tài Nguyên | The numeric ID of the product variant resource to which the metafield will be attached. |
| Dữ Liệu Trường Tùy Chỉnh | JSON object defining the metafield data to create. It includes: - namespace: grouping namespace (e.g., "inventory")- key: metafield key name (e.g., "warehouse_location")- value: the value to store (e.g., "A-12")- value_type: type of the value (e.g., "string")- description: description of the metafield's purpose |
Example of Dữ Liệu Trường Tùy Chỉnh JSON:
{
"namespace": "inventory",
"key": "warehouse_location",
"value": "A-12",
"value_type": "string",
"description": "Storage location in warehouse"
}
Output
The node outputs an array with one item containing a json property representing the created metafield object returned from the Sapo API. This object typically includes details such as the metafield's ID, namespace, key, value, value type, description, and association to the specified product variant.
If an error occurs and the node is set to continue on failure, the output will contain an error message inside the json field.
Dependencies
- Requires an active connection to the Sapo API via an API credential configured in n8n.
- The node depends on the bundled
SapoApiBaseclass to interact with the Sapo metafields endpoints. - Proper permissions on the Sapo account to create metafields on product variants are necessary.
Troubleshooting
Common issues:
- Invalid or missing resource ID: Ensure the product variant ID is correct and exists in the Sapo store.
- Malformed JSON in the metafield data: The
dataproperty must be valid JSON matching the expected metafield structure. - Insufficient API permissions: The API key used must have rights to modify metafields.
Error messages:
- Errors from the Sapo API will be surfaced with their message. For example, if the metafield key already exists or the value type is invalid, the API will return an error.
- If the node throws a generic API error, verify credentials and network connectivity.
Resolution tips:
- Validate JSON input carefully before running.
- Confirm the resource ID corresponds to a valid product variant.
- Check API credentials and permissions.
- Use the "continue on fail" option to handle errors gracefully in workflows.
Links and References
- Sapo API Documentation (general reference for metafield API)
- n8n documentation on creating custom nodes
- JSON schema guidelines for metafields (refer to Sapo API docs)