Sapo Trường Tùy Chỉnh icon

Sapo Trường Tùy Chỉnh

Quản lý trường tùy chỉnh trên Sapo

Bài Viết → Cập Nhật

AI-generated

Overview

This node manages custom metafields on various resource types within the Sapo platform. It allows users to create, retrieve, update, delete, count, and validate metafields associated with resources such as articles, blogs, collections, customers, orders, pages, products, and product variants.

A common use case is enriching resource data by adding custom metadata fields (metafields) that store additional information not covered by default properties. For example, you might add a "warehouse_location" metafield to an article or product to track inventory storage details.

Practical examples:

  • Updating a metafield on a blog post to include SEO keywords.
  • Retrieving all metafields for a specific product variant.
  • Validating a metafield value before saving it to ensure it meets expected criteria.

Properties

Name Meaning
ID Tài Nguyên The numeric ID of the resource (e.g., article, product) to which the metafield belongs.
ID Trường Tùy Chỉnh The numeric ID of the metafield to get, update, or delete.
Dữ Liệu Trường Tùy Chỉnh JSON object containing metafield data such as namespace, key, value, value type, and description. Used when creating or updating a metafield. Example structure:
json { "namespace": "inventory", "key": "warehouse_location", "value": "A-12", "value_type": "string", "description": "Storage location in warehouse" }

Output

The node outputs a JSON object representing the result of the operation:

  • For update operation (the focus here), the output JSON contains the updated metafield data returned from the API.
  • For other operations, the output varies accordingly (e.g., success status for delete, count number for count).
  • No binary data output is produced by this node.

Example output JSON for update:

{
  "id": 123,
  "namespace": "inventory",
  "key": "warehouse_location",
  "value": "A-12",
  "value_type": "string",
  "description": "Storage location in warehouse",
  "owner_type": "article",
  "owner_id": 456
}

Dependencies

  • Requires an active connection to the Sapo API via an API authentication credential configured in n8n.
  • Uses an internal helper class to interact with the Sapo metafields API endpoints.
  • No additional external dependencies beyond the Sapo API and n8n environment.

Troubleshooting

  • Common issues:

    • Invalid resource or metafield IDs may cause errors; ensure IDs correspond to existing entities.
    • Malformed JSON in the "Dữ Liệu Trường Tùy Chỉnh" property can cause parsing failures.
    • Insufficient permissions or invalid API credentials will result in authorization errors.
  • Error messages:

    • Errors from the Sapo API are caught and returned as error messages in the node output if "Continue On Fail" is enabled.
    • Typical errors include "Resource not found," "Invalid metafield ID," or "Unauthorized access."
  • Resolution tips:

    • Verify resource and metafield IDs before running the node.
    • Validate JSON input syntax carefully.
    • Confirm API credentials have necessary scopes and are correctly configured.

Links and References

Discussion