Missing product variants in bulk operation

Hello,

For at least one of my clients out of stock variants are not included in bulk operation. Query I use:

query {
  productVariants(query: "(product_status:active OR product_status:draft OR product_status:unlisted) AND (collection:264241610787)") {
    edges {
      node {
        id
        title
        sku
        price
        compareAtPrice
        
        inventoryItem {
          id
          unitCost {
            amount
          }
        }
        product {
          id
          title
          status
          isGiftCard
          variantsCount {
            count
          }
        }
      }
    }
  }
}

Inside response for product XX I get only 7 variants instead of 10. All out of stock variants are being skipped. Response includes variantsCount for each variant which also indicates 10 variants (titles in response omitted for privacy):

{"id":"gid:\/\/shopify\/ProductVariant\/40775467860003","title":"...","sku":"2825115","price":"120.00","compareAtPrice":"150.00","inventoryItem":{"id":"gid:\/\/shopify\/InventoryItem\/42869319401507","unitCost":null},"product":{"id":"gid:\/\/shopify\/Product\/7099034992675","title":"...","status":"ACTIVE","isGiftCard":false,"variantsCount":{"count":10}}}
{"id":"gid:\/\/shopify\/ProductVariant\/40775467892771","title":"...","sku":"2825120","price":"120.00","compareAtPrice":"150.00","inventoryItem":{"id":"gid:\/\/shopify\/InventoryItem\/42869319434275","unitCost":null},"product":{"id":"gid:\/\/shopify\/Product\/7099034992675","title":"...","status":"ACTIVE","isGiftCard":false,"variantsCount":{"count":10}}}
{"id":"gid:\/\/shopify\/ProductVariant\/40775467958307","title":"...","sku":"2825121","price":"120.00","compareAtPrice":"150.00","inventoryItem":{"id":"gid:\/\/shopify\/InventoryItem\/42869319499811","unitCost":null},"product":{"id":"gid:\/\/shopify\/Product\/7099034992675","title":"...","status":"ACTIVE","isGiftCard":false,"variantsCount":{"count":10}}}
{"id":"gid:\/\/shopify\/ProductVariant\/40775467991075","title":"...","sku":"2825117","price":"120.00","compareAtPrice":"150.00","inventoryItem":{"id":"gid:\/\/shopify\/InventoryItem\/42869319532579","unitCost":null},"product":{"id":"gid:\/\/shopify\/Product\/7099034992675","title":"...","status":"ACTIVE","isGiftCard":false,"variantsCount":{"count":10}}}
{"id":"gid:\/\/shopify\/ProductVariant\/40775468515363","title":"...","sku":"2825122","price":"120.00","compareAtPrice":"150.00","inventoryItem":{"id":"gid:\/\/shopify\/InventoryItem\/42869319598115","unitCost":null},"product":{"id":"gid:\/\/shopify\/Product\/7099034992675","title":"...","status":"ACTIVE","isGiftCard":false,"variantsCount":{"count":10}}}
{"id":"gid:\/\/shopify\/ProductVariant\/40775468548131","title":"...","sku":"2825123","price":"120.00","compareAtPrice":"150.00","inventoryItem":{"id":"gid:\/\/shopify\/InventoryItem\/42869320089635","unitCost":null},"product":{"id":"gid:\/\/shopify\/Product\/7099034992675","title":"...","status":"ACTIVE","isGiftCard":false,"variantsCount":{"count":10}}}
{"id":"gid:\/\/shopify\/ProductVariant\/40775468613667","title":"...","sku":"2825118","price":"120.00","compareAtPrice":"150.00","inventoryItem":{"id":"gid:\/\/shopify\/InventoryItem\/42869320155171","unitCost":null},"product":{"id":"gid:\/\/shopify\/Product\/7099034992675","title":"...","status":"ACTIVE","isGiftCard":false,"variantsCount":{"count":10}}}

Bulk operation ID: gid://shopify/BulkOperation/4189061152803

This looks like a bug. Bulk operations are critical for working with product prices with new 2048 variants limit. There’s no other way to load data anymore so I hope this issue can be resolved.

Let me know if any additional details are required.

Hey @Kirill_Platonov - thanks for raising, we’ll prioritize investigation. Will let you know if we need any more info.

1 Like

@Tim-Shopify Thank you! I just made few more tests and the issue might be related to filter by collection. When I filter by specific product_id I get all variants in bulk operation. Not sure why collection filter might impact variants, but hopefully it will simplify investigation.

Example query:

query {
  productVariants(query: "(product_status:active OR product_status:draft OR product_status:unlisted) AND (product_id:7099034992675)") {
    edges {
      node {
        id
        title
        sku
        price
        compareAtPrice
        
        inventoryItem {
          id
          unitCost {
            amount
          }
        }
        product {
          id
          title
          status
          isGiftCard
          variantsCount {
            count
          }
        }
      }
    }
  }
}

Bulk operation ID: gid://shopify/BulkOperation/4189884350499

When you filter by collection, did you get back more than 250 variants in the response? The default sort order is not by product id so the variants for a single product would be scattered throughout the response variants list. If you try to sort by “SKU” that might give you a better grouping of variants associated with the same product.

@Kenny_Law

When you filter by collection, did you get back more than 250 variants in the response?

Yes, in the first example (gid://shopify/BulkOperation/4189061152803) I got 1558 in total. I did checked the whole response file - it has only 7 variants for product 7099034992675 instead of 10. All out of stock variants are not included for that product.

The default sort order is not by product id so the variants for a single product would be scattered throughout the response variants list. If you try to sort by “SKU” that might give you a better grouping of variants associated with the same product.

That’s a good note. Is it possible to add sortKey for PRODUCT_ID? It will dramatically simplify processing of JSONL file. We won’t need to load all product variants in memory and can rely on order of variants to identify that all variants for product has been processed.