{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "sticky-main-overview",
      "name": "Sticky Note - Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -350,
        -100
      ],
      "parameters": {
        "color": 6,
        "width": 300,
        "height": 300,
        "content": "## Shopify to Odoo Sync\n\n### How it works\n1. Listens for new products in Shopify, downloads images, and creates them in Odoo.\n2. Listens for product updates in Shopify and syncs changes to Odoo.\n\n### Setup steps\n- [x] Configure Shopify Webhooks\n- [x] Configure Odoo API Credentials\n- [x] Verify Category mapping"
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-create-flow",
      "name": "Sticky Note - Create Flow",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -50,
        20
      ],
      "parameters": {
        "color": 7,
        "width": 2050,
        "height": 220,
        "content": "## 1. Product Creation Flow\nChecks if the product exists in Odoo by barcode. If not found, fetches the category, downloads the image, and creates the new product."
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-update-flow",
      "name": "Sticky Note - Update Flow",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -50,
        320
      ],
      "parameters": {
        "color": 7,
        "width": 800,
        "height": 200,
        "content": "## 2. Product Update Flow\nFinds the existing product in Odoo by barcode and syncs the updated title and price."
      },
      "typeVersion": 1
    },
    {
      "id": "a28a68e9-d2eb-4ec7-9f97-3119b457230a",
      "name": "When Product Created",
      "type": "n8n-nodes-base.shopifyTrigger",
      "position": [
        0,
        100
      ],
      "parameters": {
        "topic": "products/create",
        "authentication": "oAuth2"
      },
      "credentials": {
        "shopifyOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "643c0a73-d9c1-4d1c-aa1e-77dd829f2d91",
      "name": "Search Product by Barcode",
      "type": "n8n-nodes-base.odoo",
      "position": [
        250,
        100
      ],
      "parameters": {
        "limit": 1,
        "options": {},
        "resource": "custom",
        "operation": "getAll",
        "filterRequest": {
          "filter": [
            {
              "value": "={{ $json.variants[0].barcode }}",
              "fieldName": "barcode"
            }
          ]
        },
        "customResource": "product.template"
      },
      "credentials": {
        "odooApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "9a696458-7d18-4e88-a477-d10e055675cd",
      "name": "Process Search Result",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        500,
        100
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "63e7934d-a954-4a75-b815-f593a557b0d5",
      "name": "If Product Not Found",
      "type": "n8n-nodes-base.if",
      "position": [
        750,
        100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a2443748-c30b-4e4e-b1c4-4bd120e6e40a",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.id }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3,
      "alwaysOutputData": true
    },
    {
      "id": "9bb92bcc-9dfc-4c72-ab2a-983c7348e1ec",
      "name": "Get Product Category",
      "type": "n8n-nodes-base.odoo",
      "position": [
        1000,
        100
      ],
      "parameters": {
        "limit": 1,
        "options": {},
        "resource": "custom",
        "operation": "getAll",
        "filterRequest": {
          "filter": [
            {
              "value": "={{ $('When Product Created').item.json.vendor }}",
              "fieldName": "name"
            }
          ]
        },
        "customResource": "product.category"
      },
      "credentials": {
        "odooApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "b003f1b6-0ef8-447f-aff7-7c722626a83d",
      "name": "Download Product Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1250,
        100
      ],
      "parameters": {
        "url": "={{ $('When Product Created').item.json.images[0].src }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.3,
      "alwaysOutputData": true
    },
    {
      "id": "58f6830d-4ffe-4f6e-98b1-0c9c75cb0423",
      "name": "Convert Image to Base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1500,
        100
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery",
        "destinationKey": "final_image"
      },
      "typeVersion": 1.1
    },
    {
      "id": "9ad5f2a0-2ee7-4255-b323-bbce475496da",
      "name": "Create Product in Odoo",
      "type": "n8n-nodes-base.odoo",
      "position": [
        1750,
        100
      ],
      "parameters": {
        "resource": "custom",
        "customResource": "product.template",
        "fieldsToCreateOrUpdate": {
          "fields": [
            {
              "fieldName": "name",
              "fieldValue": "={{ $('When Product Created').item.json.title }}"
            },
            {
              "fieldName": "list_price",
              "fieldValue": "={{ $('When Product Created').item.json.variants[0].price }}"
            },
            {
              "fieldName": "barcode",
              "fieldValue": "={{ $('When Product Created').item.json.variants[0].barcode }}"
            },
            {
              "fieldName": "taxes_id",
              "fieldValue": "={{ [] }}"
            },
            {
              "fieldName": "supplier_taxes_id",
              "fieldValue": "={{ [] }}"
            },
            {
              "fieldName": "categ_id",
              "fieldValue": "={{ $('Get Product Category').item.json.id }}"
            },
            {
              "fieldName": "image_1920",
              "fieldValue": "={{ $json.final_image }}"
            }
          ]
        }
      },
      "credentials": {
        "odooApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7bb0a595-51b0-4bd3-ace5-8f9b10a88ab0",
      "name": "When Product Updated",
      "type": "n8n-nodes-base.shopifyTrigger",
      "position": [
        0,
        400
      ],
      "parameters": {
        "topic": "products/update",
        "authentication": "oAuth2"
      },
      "credentials": {
        "shopifyOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "66180fab-5e6a-480e-b9d4-47063fd45af2",
      "name": "Find Product to Update",
      "type": "n8n-nodes-base.odoo",
      "position": [
        250,
        400
      ],
      "parameters": {
        "limit": 1,
        "options": {},
        "resource": "custom",
        "operation": "getAll",
        "filterRequest": {
          "filter": [
            {
              "value": "={{ $json.variants[0].barcode }}",
              "fieldName": "barcode"
            }
          ]
        },
        "customResource": "product.template"
      },
      "credentials": {
        "odooApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "2e364f57-33bd-4a2d-9530-998a04213bd7",
      "name": "Update Product in Odoo",
      "type": "n8n-nodes-base.odoo",
      "position": [
        500,
        400
      ],
      "parameters": {
        "resource": "custom",
        "operation": "update",
        "customResource": "product.template",
        "customResourceId": "={{ $json.id }}",
        "fieldsToCreateOrUpdate": {
          "fields": [
            {
              "fieldName": "name",
              "fieldValue": "={{ $('When Product Updated').item.json.title }}"
            },
            {
              "fieldName": "list_price",
              "fieldValue": "={{ $('When Product Updated').item.json.variants[0].price }}"
            }
          ]
        }
      },
      "credentials": {
        "odooApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Get Product Category": {
      "main": [
        [
          {
            "node": "Download Product Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Product Not Found": {
      "main": [
        [],
        [
          {
            "node": "Get Product Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Product Created": {
      "main": [
        [
          {
            "node": "Search Product by Barcode",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Product Updated": {
      "main": [
        [
          {
            "node": "Find Product to Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Search Result": {
      "main": [
        [],
        [
          {
            "node": "If Product Not Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Product Image": {
      "main": [
        [
          {
            "node": "Convert Image to Base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Product to Update": {
      "main": [
        [
          {
            "node": "Update Product in Odoo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Image to Base64": {
      "main": [
        [
          {
            "node": "Create Product in Odoo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Product by Barcode": {
      "main": [
        [
          {
            "node": "Process Search Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}