Updating Products

Inside this guide:
Introduction
Update a Product
Next steps

Introduction

The updateCoreProduct mutation allows you to update a Product.

Update a product

Constructing the mutation and input

We'll be using the API Console to save time having to authenticate. Copy and paste this into your API console query section to get started. Reminder that fields can be removed from the query if you don't want the API to return them.

POST /graphql
Query

mutation ($input: UpdateCoreProductInput!) {
    updateCoreProduct(input: $input) {
        product {
            id
            name
            skuCode
            barcode
            category {
                id
                name
            }
            dimensions {
                width
                height
                length
                unit
            }
            weight {
                value
                unit
            }
            unitsPerCarton
            cbmPerUnit
            characteristics {
                hot
                hazardous
                specialHandling
                refrigerated
                stackable
                garmentsOnHangers
                healthCertificate
                riskLevel
            }
            attributes {
                attribute {
                    id
                    name
                    type
                }
                value
            }
            tariffCodes {
                tariffCode
                tariffRegionCode
            }
            sellCostPrices {
                sellCostPrice {
                    value
                    currency
                }
                mainPrice
            }
            buyCostPrices {
                buyCostPrice {
                    value
                    currency
                }
                manufacturer {
                    id
                }
                mainPrice
            }
        }
        status
        errors {
            path
            message
        }
    }
}



Defining the variables

Copy and paste the block below into the query variables section of the API console, substituting the following.

The CATEGORY_UUID and ATTRIBUTE_UUID can be retrieved when creating a category CreateCoreProductCategory and creating an attribute CreateCoreProductAttribute or querying a category QueryCoreProductAttribute or querying attribute QueryCoreProductAttribute.

Variables

{
  "input": {
    "name": "Blue T-Shirts",
    "skuCode": "10000",
    "barcode": "J48fFJ3811",
    "categoryId": CATEGORY_UUID,
    "dimensions": {
      "width": 5,
      "height": 10,
      "length": 20,
      "unit": "CM"
    },
    "weight": {
      "unit": "G",
      "value": 100
    },
    "unitsPerCarton": 5,
    "characteristics": {
      "hot": false,
      "hazardous": false,
      "specialHandling": false,
      "refrigerated": false,
      "stackable": true,
      "garmentsOnHangers": false,
      "healthCertificate": false,
      "riskLevel": "LOW"
    },
    "attributes": {
      "attributeId": ATTRIBUTE_UUID,
      "value": "Blue"
    },
    "tariffCodes": {
      "tariffRegionCode": "GB",
      "tariffCode": "12345678"
    },
    "sellCostPrices": {
      "sellCostPrice": {
        "value": 5,
        "currency": "GBP"
      },
      "mainPrice": true
    },
    "buyCostPrices": {
      "buyCostPrice": {
        "value": 5,
        "currency": "GBP"
      },
      "manufacturerId": SUPPLIER_UUID
      "mainPrice": true
    }
  }
}

Now press Execute Query (the play button) to send the request.

You should get back this response containing all the requested product data of the id you provided.

NOTE: The various ids e.g. product id and category id will not match what you get back in the actual response.

JSON Response

{
  "data": {
    "updateCoreProduct": {
      "product": {
        "id": "cfeeb6ee-91c4-46b1-9411-71185d359324",
        "name": "Blue T-Shirts",
        "skuCode": "10000",
        "barcode": "J48fFJ3811",
        "category": {
          "id": "b426b1d7-6210-4cd1-ac65-b3dc184c473b",
          "name": "Clothes"
        },
        "dimensions": {
          "width": 5,
          "height": 10,
          "length": 20,
          "unit": "CM"
        },
        "weight": {
          "unit": "G",
          "value": 100
        },
        "unitsPerCarton": 5,
        "cbmPerUnit": 100,
        "characteristics": {
          "hot": false,
          "hazardous": false,
          "specialHandling": false,
          "refrigerated": false,
          "stackable": true,
          "garmentsOnHangers": false,
          "healthCertificate": false,
          "riskLevel": "LOW"
        },
        "attributes": [
          {
            "attribute": {
              "id": "b6e596dd-203b-4867-a553-b782d5b0ea10",
              "name": "Colour",
              "type": "TEXT"
            },
            "value": "Blue"
          }
        ],
        "tariffCodes": [
          {
            "tariffRegionCode": "GB",
            "tariffCode": "12345678"
          }
        ],
        "sellCostPrices": [
          {
            "sellCostPrice": {
              "value": 5,
              "currency": "GBP"
            },
            "mainPrice": true
          }
        ],
        "buyCostPrices": [
          {
            "buyCostPrice": {
              "value": 5,
              "currency": "GBP"
            },
            "manufacturer": {
              "id": "b426b1d7-6210-4cd1-ac65-b3dc184c473b"
            },
            "mainPrice": true
          }
        ],
        "status": "ACTIVE"
      },
      "errors": []
    }
  }
}

This will result in the product being updated.

Next Steps