Skip to main content
Skip table of contents

Importing Products

Triggering import_product_from_url from the UI

Preconditions

  1. You have Setup Test Environment

  2. You created a Store (Integration) and implemented Authentication

  3. The Store you’re importing from is Healthy and Enabled

    1. Verify by visiting the stores’s edit screen. (Settings, Stores, Store)

Steps

  1. Click on “Products“ - left menu

  2. Click on “Import“ - button, top right

  3. You are presented with Stores you can import products from

  4. Paste product URL into the input box and

  5. Navigate to settings, stores, the store you’re developing for

  6. See the directive in logs

Servicing the import_product_from_url directive

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

JSON
// POST <https://yourhost/.../path/INTEGRATION_ID>
{
  "directives": [
    {
      "args": {
        "product_url": "https://mertchants-store.com/products/some-product-id"
      },
      "directive": "import_product_from_url",
      "id": "47e92567-e45f-4f35-a0e3-4d6322340c82"
    }
  ]
}

Success response

“result“ (line 4) below should contains Katalys’ product ID.

CODE
{
  "results": [
    {
      "result": "042bd63f-02d2-43d2-8446-46f0a12ce076", // katalys product id
      "source_directive": "import_product_from_url",
      "source_id": "47e92567-e45f-4f35-a0e3-4d6322340c82",
      "status": "ok"
    }
  ]
}

Error response

Set the the status to “error“ and write your own error message.

CODE
{
  "results": [
    {
      "error": "Unusable URL: https://unusable.com/products/wrong",
      "source_directive": "import_product_from_url",
      "source_id": "47e92567-e45f-4f35-a0e3-4d6322340c82",
      "status": "error"
    }
  ]
}

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 Katalys platform user can just grab a public url and turn it into a functional Katalys 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.

Creating the product

GRAPHQL
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:

  • A product can have zero, one, or many variants.

  • When a shop offers a product with variants, a buyer will only be able to purchases one of the variants — never the parent product. The Checkout flow preselects a variant and the buyer is able to switch between the rest of the variants.

  • Both variants and products share the same attributes and are represented with the Product. During the checkout process, a variant inherits attributes from the parent product. Therefore the variant only needs to specify values that make it different from the parent product.

  • The external_id attribute is free form text and it’s your decision what to put in there, it should allow you to find the product/variant in the merchant’s store

  • option_names is present on the product and defines available options for the user to chose from.

  • option_1_names_path and option_2_names_path are present on the variant and define which options need to be selected for the variant to be chosen.

Example variables for the createOrder() input value.

JSON
{
  "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"
        ]
      }
    ]
  }
}

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.