Item attribute values not being set correctly through API

aaronaaron Posts: 44Member
Hi,

We have a middleware which can create new ItemMatrixes and add Items to it through the Retail API.

The matrix in question has the Color/Size itemAttributeSet.
The matrix is created just fine in Lightspeed.

Then I queue buffers to create Items for this Matrix. Each buffer creates an Item. In this case the Color for the items is the same (MATT BLACK/GOLD) and the Size is different (L, ML, etc).

My buffers are sent asynchronously from each other and end up sending the following json payload:
{
  "description": "X70 AGV E2205 SOLID -",
  "ean": "8026656667444",
  "manufacturerSku": None,
  "customSku": "8026656667444",
  "publishToEcom": True,
  "Prices": {
    "ItemPrice": [
      {
        "amount": 35.0,
        "useTypeID": "1",
        "useType": "Default"
      },
      {
        "amount": None,
        "useTypeID": "2",
        "useType": "MSRP"
      },
      {
        "amount": 45.0,
        "useTypeID": "3",
        "useType": "Online"
      }
    ]
  },
  "CustomFieldValues": {
    "CustomFieldValue": {
      "customFieldID": "1",
      "value": "0021A4I0"
    }
  },
  "ItemAttributes": {
    "itemAttributeSetID": "1",
    "attribute1": " MATT BLACK/GOLD",
    "attribute2": "L"
  },
  "itemMatrixID": "116"
}
And then times 6 for each size (L, ML, MS, S, XL, XS).

The response I receive looks like this:
{
  "@attributes": {
    "count": "1"
  },
  "Item": {
    "itemID": "234",
    "systemSku": "210000000235",
    "defaultCost": "0",
    "avgCost": "0",
    "discountable": "true",
    "tax": "true",
    "archived": "false",
    "itemType": "default",
    "serialized": "false",
    "description": "X70 AGV E2205 SOLID - MATT BLACK/GOLD L",
    "modelYear": "0",
    "upc": "",
    "ean": "8026656667444",
    "customSku": "8026656667444",
    "manufacturerSku": "",
    "createTime": "2018-12-18T08:24:37+00:00",
    "timeStamp": "2018-12-18T08:24:37+00:00",
    "publishToEcom": "true",
    "categoryID": "0",
    "taxClassID": "1",
    "departmentID": "0",
    "itemMatrixID": "116",
    "manufacturerID": "0",
    "seasonID": "0",
    "defaultVendorID": "0",
    "ItemAttributes": {
      "attribute1": " MATT BLACK/GOLD",
      "attribute2": "L",
      "attribute3": "",
      "itemAttributeSetID": "1"
    },
    "ItemMatrix": {
      "itemMatrixID": "116",
      "description": "X70 AGV E2205 SOLID -",
      "tax": "true",
      "defaultCost": "0",
      "itemType": "default",
      "serialized": "false",
      "modelYear": "0",
      "archived": "false",
      "timeStamp": "2018-12-18T08:24:37+00:00",
      "itemAttributeSetID": "1",
      "manufacturerID": "0",
      "categoryID": "0",
      "defaultVendorID": "0",
      "taxClassID": "1",
      "seasonID": "0",
      "departmentID": "0",
      "Prices": {
        "ItemPrice": [
          {
            "amount": "0",
            "useTypeID": "1",
            "useType": "Default"
          },
          {
            "amount": "0",
            "useTypeID": "2",
            "useType": "MSRP"
          },
          {
            "amount": "0",
            "useTypeID": "3",
            "useType": "Online"
          }
        ]
      },
      "attribute1Values": "MATT BLACK/GOLD",
      "attribute2Values": [
        "S",
        "ML",
        "XL",
        "XS",
        "MS",
        "L"
      ]
    },
    "ItemShops": {
      "ItemShop": [
        {
          "itemShopID": "701",
          "qoh": "0",
          "backorder": "0",
          "componentQoh": "0",
          "componentBackorder": "0",
          "reorderPoint": "0",
          "reorderLevel": "0",
          "timeStamp": "2018-12-18T08:24:38+00:00",
          "itemID": "234",
          "shopID": "1"
        },
        {
          "itemShopID": "700",
          "qoh": "0",
          "backorder": "0",
          "componentQoh": "0",
          "componentBackorder": "0",
          "reorderPoint": "0",
          "reorderLevel": "0",
          "timeStamp": "2018-12-18T08:24:37+00:00",
          "itemID": "234",
          "shopID": "0"
        }
      ]
    },
    "CustomFieldValues": {
      "CustomFieldValue": {
        "customFieldValueID": "219",
        "customFieldID": "1",
        "name": "productCode",
        "type": "string",
        "value": "0021A4I0"
      }
    },
    "Prices": {
      "ItemPrice": [
        {
          "amount": "35",
          "useTypeID": "1",
          "useType": "Default"
        },
        {
          "amount": "0",
          "useTypeID": "2",
          "useType": "MSRP"
        },
        {
          "amount": "45",
          "useTypeID": "3",
          "useType": "Online"
        }
      ]
    }
  }
}
As you can see, according to the json response I receive from your API, the Item attributes are set just fine.
But when I open Lightspeed Retail I see the following:


As you can see the Color has not been set, even though according to your API response it has. The name of the items also includes the Color, so I am genuinely confused what is going on here.


What is going wrong here? Does it have something to do with them all having the same color?

Tags:

2 comments

  • Adrian SamuelAdrian Samuel Posts: 499Moderator, Lightspeed Staff moderator
    @aaron I spent some significant time looking into this today. There are some known bugs regarding the behaviour of this endpoint.

    It's hard to pin down exact reproducible behaviour but when you've got duplicate attribute1 values, the system can occasionally void all of attribute1. You can try to do another GET on the item and reset the attributes and sometimes that fixes it.
    So you might essentially want to loop on the item list associated with the itemMatrixID (parent Matrix) and check it's been done correctly

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

Sign In or Register to comment.