8
n8n 中文网amn8n.com

Adobe Commerce(Magento 2)自动化产品描述生成

中级

这是一个Miscellaneous, Multimodal AI领域的自动化工作流,包含 13 个节点。主要使用 Set, Code, Merge, HttpRequest, ManualTrigger 等节点。 使用Azure OpenAI为Adobe Commerce/Magento自动生成产品描述

前置要求
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "LVoDtVFQ069sOYcC",
  "meta": {
    "instanceId": "965bb8e7bf93f91108971d05aa397ffa90b643c7ff8c03d51df51a28ffdc99dc",
    "templateCredsSetupCompleted": true
  },
  "name": "Adobe Commerce (Magento 2) 自动化产品描述生成",
  "tags": [],
  "nodes": [
    {
      "id": "7272f57f-3ebd-4a5d-a3ae-1c6a16e0a140",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1504,
        16
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1e10c1ee-3777-466e-ab0f-a211046f4114",
      "name": "保存可配置项",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        64,
        16
      ],
      "parameters": {
        "url": "=https://www.example.com/rest/V1/products/{{ encodeURIComponent($('get Product without description').first().json.items[0].sku) }}",
        "method": "PUT",
        "options": {},
        "jsonBody": "={\n  \"product\": {\n    \"custom_attributes\": [{\n        \"attribute_code\": \"description\",\n        \"value\": \"{{ $json.description.replaceAll('\\n',' ').replaceAll('\"\"','\\\\\"') }}\"\n      }]\n  }\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "magento2Api"
      },
      "credentials": {
        "magento2Api": {
          "id": "yGyqOmSuvrgMUFB9",
          "name": "Magento 2 PROD"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5373fa9b-e857-435f-a3ae-08978e7717df",
      "name": "设置描述",
      "type": "n8n-nodes-base.set",
      "position": [
        -128,
        16
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c21f389d-4104-4a6f-b616-324abb221798",
              "name": "description",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e127791d-b564-4c23-86a2-a55cbe1bad49",
      "name": "基础 LLM 链",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -528,
        16
      ],
      "parameters": {
        "text": "=Write an English product description based on this Magento2 attributes. Please use html paragraphs and breaks only. Ensure the text is grammatically correct, natural, and tailored to the ... market. Use terminology that is common in this sector, and avoid overly literal or informal style. \n\nWrite in a consistent style suitable for webshop product descriptions: professional, clear, and customer-oriented, while keeping a persuasive tone aimed at ...\n\nAdditionally, make the text SEO-friendly : include relevant keywords naturally without unnecessary repetition, and ensure the text reads smoothly while supporting search visibility.\n\nHere is the Magento product: {{  JSON.stringify($json) }}",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "487315aa-572d-40a4-ba61-a091b8157061",
      "name": "Azure OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        -528,
        192
      ],
      "parameters": {
        "model": "model-router",
        "options": {}
      },
      "credentials": {
        "azureOpenAiApi": {
          "id": "Skyi4ZtQphRSSRSw",
          "name": "Azure Open AI account 4"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5198d2bb-89db-401a-bf35-21884378c2f5",
      "name": "等待节点就绪",
      "type": "n8n-nodes-base.merge",
      "position": [
        -1040,
        16
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "3807a3cf-d7aa-4315-8d25-cc6386b1181a",
      "name": "获取无描述的产品",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1264,
        -128
      ],
      "parameters": {
        "url": "=https://www.example.com/rest/V1/products",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "searchCriteria[filter_groups][0][filters][0][field]",
              "value": "description"
            },
            {
              "name": "searchCriteria[filter_groups][0][filters][0][condition_type]",
              "value": "null"
            },
            {
              "name": "searchCriteria[pageSize]",
              "value": "1"
            }
          ]
        },
        "nodeCredentialType": "magento2Api"
      },
      "credentials": {
        "magento2Api": {
          "id": "yGyqOmSuvrgMUFB9",
          "name": "Magento 2 PROD"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9c551919-8e15-44bb-937b-3ae06dc5ffc2",
      "name": "准备属性",
      "type": "n8n-nodes-base.code",
      "position": [
        -720,
        16
      ],
      "parameters": {
        "jsCode": "// Assuming the JSON data is stored in a variable called \"jsonData\"\nconst product = $(\"get Product without description\").first().json.items[0];\nconst data = $('Get attributes and options').first().json.items; // Extract the items containing attributes and options\nconst customAttributes = product.custom_attributes; // Extract the custom attributes\n//console.log(customAttributes);\n// Create a map of attribute_code to their options (for select-type attributes)\nconst attributeOptionsMap = {};\nfor (const attribute of data) {\n    if (attribute.options) {\n        attributeOptionsMap[attribute.attribute_code] = attribute.options;\n    }\n}\n// Loop over all custom attributes to check if they exist in the attributeOptionsMap\nfor (const customAttribute of customAttributes) {\n    const attributeCode = customAttribute.attribute_code;\n            //console.log(attributeCode);\n\n    // Check if this custom attribute exists in the attributeOptionsMap (i.e., it has options)\n    if (attributeOptionsMap[attributeCode]) {\n      \n        const attributeOptions = attributeOptionsMap[attributeCode];\n        const value = customAttribute.value;\n            //console.log(value);\n\n        // Find the label corresponding to the current value\n        const matchingOption = attributeOptions.find(option => option.value === value);\n        if (matchingOption) {\n            // Replace the value with the label\n            customAttribute.value = matchingOption.label;\n        }\n    }\n}\n// After this, customAttributes will have all applicable values replaced by their labels\nproduct.custom_attributes = customAttributes;\nreturn product;"
      },
      "typeVersion": 2
    },
    {
      "id": "88d7173a-e816-4530-87e5-6be43f44b5b2",
      "name": "获取属性和选项",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1264,
        144
      ],
      "parameters": {
        "url": "https://www.example.com/rest/V1/products/attributes?searchCriteria[filter_groups][0][filters][0][field]=frontend_input&searchCriteria[filter_groups][0][filters][0][value]=select&fields=items[frontend_input,attribute_code,default_frontend_label,options]",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "magento2Api"
      },
      "credentials": {
        "magento2Api": {
          "id": "yGyqOmSuvrgMUFB9",
          "name": "Magento 2 PROD"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.2
    },
    {
      "id": "50edd904-37c6-44cb-860c-023041f51892",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        -336
      ],
      "parameters": {
        "color": 4,
        "width": 720,
        "height": 704,
        "content": "### 步骤 1:从 Magento 获取产品信息"
      },
      "typeVersion": 1
    },
    {
      "id": "7f7d74f8-2203-4268-a342-193b2c01eac9",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        -336
      ],
      "parameters": {
        "color": 6,
        "width": 560,
        "height": 704,
        "content": "### 步骤 2:使用 LLM 生成描述"
      },
      "typeVersion": 1
    },
    {
      "id": "3eef5219-71a7-4409-a135-658c8fe42a5c",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        -336
      ],
      "parameters": {
        "color": 2,
        "width": 560,
        "height": 704,
        "content": "### 步骤 3:在 Magento 中保存产品"
      },
      "typeVersion": 1
    },
    {
      "id": "62670ee5-58ad-45fc-b07e-f6d0885c4b98",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2464,
        -336
      ],
      "parameters": {
        "width": 880,
        "height": 1664,
        "content": "# 🛍️ Adobe Commerce (Magento 2) 自动化产品描述生成"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "11259216-9fa3-4fea-b872-e36c88d412c8",
  "connections": {
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "set Description",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set Description": {
      "main": [
        [
          {
            "node": "Save configurable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save configurable": {
      "main": [
        [],
        []
      ]
    },
    "Prepare attributes": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait until nodes ready": {
      "main": [
        [
          {
            "node": "Prepare attributes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Azure OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get attributes and options": {
      "main": [
        [
          {
            "node": "Wait until nodes ready",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "get Product without description": {
      "main": [
        [
          {
            "node": "Wait until nodes ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Get attributes and options",
            "type": "main",
            "index": 0
          },
          {
            "node": "get Product without description",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 杂项, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量13
分类2
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流