Can't set product status to "archived"

sfsdev
Tourist
10 0 6

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

0 Likes
BoxUp
Shopify Partner
33 1 11

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.

0 Likes
sfsdev
Tourist
10 0 6
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


0 Likes
sfsdev
Tourist
10 0 6

@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

0 Likes
BoxUp
Shopify Partner
33 1 11

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;
}

 

 

0 Likes
sfsdev
Tourist
10 0 6

@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
33 1 11

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.

0 Likes
HunkyBill
Shopify Expert
4359 36 462

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
Tourist
10 0 6

@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
Tourist
10 0 6

@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

0 Likes