跳到主要内容
Acenda
EN中文
登录 预约演示
预约演示
Acenda 后台培训渠道集成3:13

在 PostingTemplate 中使用 Twig

在 PostingTemplate 属性中使用 Twig 调用商品数据、添加条件并格式化数值,然后在预览窗格中检查结果。

您将学到

  1. 打开渠道的 Posting Templates,选择一个属性,在 Twig 标签页中设置条件和格式
  2. 用双花括号输出数值,用 if、for 和 set 标签编写逻辑,并用 raw、lower 和 default 等过滤器转换数值
  3. 保存前先查看预览窗格;结果为空通常是变量路径有误,切勿硬编码销售渠道 ID

在 Acenda 中的位置

Acenda 后台中的菜单路径。

CHANNELS > Integrations > Edit > Posting Templates > attribute > Twig tab

视频文字稿

文字稿为英文,与视频讲解内容一致。

Use Twig in a PostingTemplate. Twig is the template language behind the Value Type tabs on your PostingTemplates. It pulls in your product data, applies conditions, and formats the result the way a channel expects.

Under Channels, Integrations, click Edit on a sales channel, open its Posting Templates, and pick an attribute. Each value has String, Property and Twig tabs. Twig is where conditions and formatting live. The same three tabs appear in Generic Templates and in Commonality rules. A few recurring export feeds also use Twig.

If you're not sure whether yours does, ask Acenda support.

Double curly braces output a value, such as product dot sku. Tags made of a curly brace and a percent sign run logic, like if, for and set. A pipe adds a filter that changes the value on its way out. Raw outputs real HTML instead of escaped text, lower makes text lowercase, length counts items, round rounds a number, and default fills in a value when a field is empty. Wrap a block in apply spaceless to remove extra whitespace, and use comment tags for notes that never print.

Here's an example for a color attribute. It checks whether one of the product's variant options is named color and has more than one value. If so, it outputs the variant's color field with the raw filter. The variables you can use depend on where you write Twig. In a posting template, you'll often use product dot sku, product dot variant options, and variant dot fields for a custom field on the variant.

Before you save, check the preview pane next to the editor. It shows exactly what your formula produces, and if something doesn't parse, it shows the error in plain English. If the output is blank, check the variable path. Twig doesn't flag an unknown or empty variable. It prints nothing.

When a mapped attribute comes out blank, Acenda leaves it out instead of sending an empty value, so the channel keeps what it already has. If HTML tags show as plain text, add the raw filter. And don't hardcode sales channel IDs, because they differ from one Acenda account to the next. An AI assistant can help you draft or debug a formula. Describe the data and the logic you need, then test the result in the preview pane.

To recap: pick the Twig tab on a template attribute, output values with curly braces, add logic and filters, and check the preview pane before you save. Questions? We're here to help. Chat with Acenda support in Acenda Admin, or visit acenda.com/help.

以纯文本打开文字稿

接下来观看

全部培训视频 →
2:39 渠道集成创建类目刊登模板为平台类目创建刊登模板,并映射其必填字段。 2:45 渠道集成设置 Commonality设置 Commonality,即某个渠道的每个类目模板都以其为起点的默认属性映射。

想了解上线流程是怎样的?

预约演示

或者联系我们。

Acenda 提供这些资源仅供参考。我们力求内容准确,但其中仍可能存在错误、疏漏或遗漏,信息也可能过时。供应商应自行审慎判断,必要时咨询律师,并向相关销售渠道确认最新要求。