Updating default variant via api to circumvent ecom bug

thpsthps Member Posts: 10
edited June 2021 in Development

Due to a bug in ecom some products occasionally fail to update the default variant to the next in stock product. Causing some in stock product to appear as out of stock.

While we wait for this bug to be resolved, I've written a script to address the issue.

-It searches through all variants

-identifies any variant where the default product is out of stock and stock is present elsewhere in the matrix.

So far so good all of this works.

-The idea is then to update the affected product's default to an in stock variant.

Using the php client as documented on the api page:

$updateVariant=$client->variants->update($newDefaultId, [

   "isDefault"      => true,



Unfortunately I get the following error:

"The server understood the request, but is refusing to fulfill it: No "update" permission to "products" using this key"

Please advise, this bug is a major problem for us. If this is not something that can be run with our api key can someone in support put my script on a daily cron job or something?



  • Ali_MasoumieAli_Masoumie Moderator, Lightspeed Staff Posts: 313 moderator


    Do you have an Omni shop (eCom & Retail)?

    If so, your eCom API key does not have update permissions on products as Retail is leading.

  • thpsthps Member Posts: 10

    It is an omni shop.

    So if my key won't work can someone in support run it on my behalf?

    After all, this is to fix a bug on your end.

    Do you have any other sugesstions to address this issue?

  • Ali_MasoumieAli_Masoumie Moderator, Lightspeed Staff Posts: 313 moderator


    Unfortunately we can not run automated scripts on your behalf. I would like to advise you to reach out to our Support (send in a ticket) to see what we can do to help you with this issue.

  • thpsthps Member Posts: 10

    I've contacted support in regards to this. They informed me it is a known issue and will be fixed eventually. This known issue has existed since we started with ecom 2 years ago and is still not resolved.

    From our point of view you would not be running the script on our behalf. You would be running a script (generously provided to you for free) to fix a bug in your software affecting your clients. Really you should probably be running this once a day on everyone's store until the default bug is fixed.

    The alternative is to grant update permissions for my key. It's worth noting that the "isDefault" property has no link to retail and therefore the fact that we are omnichannel should not matter.

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 991 moderator

    Hi @thps,

    Thank you for contacting us.

    This is not a bug, since you're having an Omni shop which is leading, it is not allowed to write products with eCom API. We have an internal case with our devs to make it possible to update certain field which don't affect Retail. I will create a ticket for you, when there are any updates on that, you'll be notified directly, unfortunately I can't give you any ETA.

    I hope this helps.

Sign In or Register to comment.