FROM CACHE - en_header

Can't set product status to "archived"

sfsdev
Excursionist
12 1 10

Hello,

  We're trying to use the Admin API 2020-10 to archive a number of older products. We're using the REST PUT requests documented here. The docs say there are 3 supported values: active, archived and draft. The example PUT request uses the "draft" status. However, when we run that request it never updates the status. The response comes back with HTTP 200 OK but the body of it still shows "status" : "active" and when checking the product in the catalog is is in fact active.

  The release notes for 2020-10 also mention this feature so we expected it to function. Is the "archived" status actively supported in the Admin API 2020-10 REST interface? Are we missing something? Doing something wrong?

// request url
// https://<secret>:<value>@<domain>/admin/api/2020-10/products/4994767192197.json

// request body
{
  "product": {
    "id": 4994767192197,
    "status": "archived"
  }
}

// response body
{
    "product": {
        "id": 4994767192197,
         // ...
        "status": "active",
        // ...
    }
}

 

Thanks,

sfsdev

 

Screenshot of status docsScreenshot of status docsScreenshot of release notesScreenshot of release notes

Replies 16 (16)
BoxUp
Shopify Partner
38 1 15

Hey,

I don't have any real reason to suspect this will work, but if you're still stuck, you could try setting the 'published_status' to 'unpublished' at the same time?

Just popped into my head when I read your post.

sfsdev
Excursionist
12 1 10
Click to expand...
BoxUp,

  Thanks for your input. We basically already have them unpublished but they still show up in the catalog when searching for products. Our thoughts were that this would hide them in the catalog. Similar to the way Orders are archived. You can find them but you have to specifically look for them.

  A few months ago there was a Shopify video where they made number of announcements about big updates and improvements. I remember hearing about this around that time. I watched a video where there was an "archive" option when editing a Product on the Admin portal. This issue seems to be that feature, documented and mentioned in the release notes for 2020-10, but doesn't seem to work.

  Anyone from the Shopify side have input on this? I tried a support chat but was quickly redirected to the community forum. It's great to pay lots of money for a product and be told to ask the public when you need some support.

sfsdev


sfsdev
Excursionist
12 1 10

@BoxUp,

  I tried setting the Product's "published_status" to "unpublished" but it didn't reflect that change. There isn't a "published_state" property for Products. The docs only mention "published_status" as a filter to the GET requests.

  It's interesting that I can't adjust the "published_scope" to anything but "web" or "global." What if I want to unpublish it? In other words, what's the REST API's equivalent to the UI's dialog where you uncheck all Sales Channels for a Product and apply it?

Thanks,

sfsdev

BoxUp
Shopify Partner
38 1 15

Sorry that wasn't much help. Not something I've attempted before.

I assume you're using the REST API for this? Have you tried the GraphQL API productChangeStatus instead? I've not got around to using it much but I know you can do something like this in Node, for example. Just need to add your product ID, shop and access token.

 

 

let query = `mutation productChangeStatus($productId: ID!, $status: ProductStatus!) {
    productChangeStatus(productId: $productId, status: 'archived') {
      product {
        id
      }
      userErrors {
        code
        field
        message
      }
    }
  }`;
  
async function graphql(query) {
  const fetch = require("node-fetch");
    let res = await fetch(`https://SHOP/admin/api/2020-10/graphql.json`, {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
            "X-Shopify-Access-Token": ACCESS_TOKEN
        },
        body: JSON.stringify(query)
    });
    let final = await res.json();
    return final;
}

 

 

sfsdev
Excursionist
12 1 10

@BoxUp,

  Thanks for the example code. We're pretty far down the REST API path. We'll switch over to GraphQL if absolutely necessary. Just wish the REST API worked the way the documents say it's supposed to. Hopefully someone from Shopify will chime in and we're missing something simple.

Thanks Again,

sfsdev

BoxUp
Shopify Partner
38 1 15

I know it isn't the greatest solution but it's essentially the same amount of work involved as using the REST API here as it'll be just one request. 

Yeah, I seem to run into a lot of issues and the support has been, quite honestly, shameful. So I'm trying to do my best to help out, even if it's not too useful, ha.

HunkyBill
Shopify Expert
4769 54 555

Once you setup the GQL, it seems strange to use Rest. I used think Rest was good enough for me too.

The main problem is, moving forward, I can see Rest getting left behind. Only GQL will be supported with the latest stuff. Amazingly though, there remain some things you can still only do with Rest, so there is that.

I think published status is a huge internal mess at the moment, hopefully, ironed out soon? I am playing in that same sandbox and nothing matches the docs for reality in a lot of places.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
sfsdev
Excursionist
12 1 10

@HunkyBill,

  Thanks for your input. After minimal development I also feel that the community here, and Shopify, are leaning towards GraphQL over REST. The documentation seems thorough. I just wish it matched what the code actually does. Regardless, it's good to know I'm not going crazy and others are experiencing the same headaches.

Thanks Again,

sfsdev

 

sfsdev
Excursionist
12 1 10

@BoxUp  & @HunkyBill,

  Well I tried the GraphQL solution and, unfortunately, it doesn't work. The productChangeStatus mutation runs without issue. It just ignores the ARCHIVED status. Using GraphQL version 2020-10.

 

// https://<shop>.myshopify.com/admin/api/2021-01/graphql.json

// mutation
mutation productChangeStatus($productId: ID!, $status: ProductStatus!) {
  productChangeStatus(productId: $productId, status: $status) {
    product {
      id
    }
    userErrors {
      code
      field
      message
    }
  }
}

// variables
{
  "productId": "gid://shopify/Product/<valid product id>",
  "status": "ARCHIVED"
}

 

  After that runs I lookup the same product id ...

// query
{
  product(id: "gid://shopify/Product/<same product id>") {
    title
    description
    status
  }
}

// response
{
    "data": {
        "product": {
            "title":  ...
            "description": ...
            "status": "ACTIVE"
        }
    },
...
}

 

  I also I tried the "DRAFT" status. That didn't stick. Switched to the 2021-01 candidate version of GraphQL. Still no go. Documented feature that straight up doesn't work.

  It's awesome that these powerful APIs are available for Shopify stores and I'm excited to dig deeper. It's just so frustrating to chase a feature for two days that's supposed to work. <insert angry emoji here>

Frustrated,

sfsdev

_JB
Shopify Staff
Shopify Staff
836 99 211

Hey @sfsdev,

I'm seeing the same thing with regards to updating product status through the API, so it's not an issue with your calls. It's a holiday here today but I'll check with our teams tomorrow and get back to you here with an update.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

HunkyBill
Shopify Expert
4769 54 555

Happy Thanksgiving!

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
_JB
Shopify Staff
Shopify Staff
836 99 211

Hello all,

Just to follow up on this. In order to ensure a smooth transition while introducing new functionality around product status, the rollout for this feature will be happening incrementally for shops over the next few weeks. During this time a given shop may or may not have the feature enabled, if the feature isn't enabled you'll see the status remain the same after attempting to update it. Our API docs are being updated to indicate this as well. Once the rollout is complete for all shops, I'll post back here to confirm. 

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

sfsdev
Excursionist
12 1 10

@_JB,

  Thanks for the update. Great to hear there's a solution in the works and the docs are being updated to reflect the rollout. I'll check back for updates over the next few weeks.

Thanks Again,

sfsdev

ozzyonfire
Shopify Partner
23 1 11

Hi there,

I'm also experiencing issues archiving products from the API. Our shop received the new update maybe a week and a half ago... Still unable to archive anything from the API. Seems like the status property on the item is just ignored. 

Has anyone else been able to get this to work?

DGP
Excursionist
12 0 5

Hi, what's the status of this?

We have this in the UI of our store admin now, is it actually functional in the APIs too?

Also, is there documentation of what this new feature means and how a store which used the Publications to indicate availability for sale should migrate to looking at and using this field? EDIT: Found it. This is what I was looking for: https://shopify.dev/tutorials/use-statuses-to-identify-filter-and-manage-products?itcat=partner_blog...

HunkyBill
Shopify Expert
4769 54 555

There is a special GQL call to set status

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com