Servicing the import_product_from_url directive

A 1o platform user wants to import a new product from the Merchant’s store.

POST <https://yourhost/.../path/INTEGRATION_ID>
{
  "directives": [
    {
      "args": {
        "product_url": "<https://mertchants-store.com/products/some-product-id>"
      },
      "directive": "import_product_from_url"
    }
  ]
}

Use the received product_url to work out which product to import. Ideally we’d like to be able to process public product pages, so a 1o platform user can just grab a public url and turn it into a functional 1o shop. This does not mean you should be scraping data from the public page, but identify the product and import it properly. For example in some integrations we support importing from a public page and an admin page.

mutation Create($input: ProductInput!) {
  createProduct(input: $input) {
    id
  }
}

Below we specify an example of how variables for the above mutation can look like. It is important to understand the following concepts:

{
  "input": {
    "name": "Intenal prduct name",
    "title": "Public product title",
    "currency": "USD",
    "currency_sign": "$",
    "price": 120,
    "compare_at_price": 140,
    "summary_md": "### Short product summary",
    "summary_html": "<h3>Short product details</h3>",
    "details_md": "### Long product details",
    "details_html": "<h3>Long product details</h3>",
    "external_id": "p1",
    "shop_url": "<https://shop.io/product/p1>",
    "images": [
      "<https://cdn.io/image1.jpg>",
      "<https://cdn.io/image2.jpg>"
    ],
    "option_names": [
      {
        "name": "Color",
        "position": 1,
        "options": [
          {
            "name": "Pink",
            "position": 1
          },
          {
            "name": "Yellow",
            "position": 2
          }
        ]
      },
      {
        "name": "Size",
        "position": 2,
        "options": [
          {
            "name": "L",
            "position": 1
          },
          {
            "name": "M",
            "position": 2
          }
        ]
      }
    ],
    "variant": false,
    "variants": [
      {
        "subtitle": "Pink / L",
        "price": 120,
        "compare_at_price": 140,
        "currency": "USD",
        "currency_sign": "$",
        "external_id": "v1",
        "shop_url": "<https://shop.io/product/p1/variants/v1>",
        "variant": true,
        "images": [
          "<https://cdn.io/image1_pink.jpg>",
          "<https://cdn.io/image2_pink.jpg>"
        ],
        "option_1_names_path": [
          "Color",
          "Pink"
        ],
        "option_2_names_path": [
          "Size",
          "L"
        ]
      },
      {
        "subtitle": "Yellow / M",
        "price": 130,
        "compare_at_price": 130,
        "currency": "USD",
        "currency_sign": "$",
        "external_id": "v2",
        "shop_url": "<https://shop.io/product/p1/variants/v2>",
        "variant": true,
        "images": [
          "<https://cdn.io/image1_yellow.jpg>",
          "<https://cdn.io/image2_yellow.jpg>"
        ],
        "option_1_names_path": [
          "Color",
          "Yellow"
        ],
        "option_2_names_path": [
          "Size",
          "M"
        ]
      }
    ]
  }
}