Since there is no such thing as "Give me a count of variants (SKUs)", and the fastest API method is to
- get all the products in a store. Since you get 250 per API call, this is relatively efficient, but slows considerably after the API limits are reached.
- each product provides a count of their variants without any API calls, so this become a simple sum in a loop of each product's variants
In a small store this is fast... but in a large one.. it is really slow... a sample benchmark of 3 runs is below.. note the tiny shop size. Tried with store with 70,000 products and ran into a brick wall on the practicality of this...
user system total real
Getting 53 Products from Shopify... SKU count = 123
0.020000 0.010000 0.030000 ( 0.931971)
0.030000 0.000000 0.030000 ( 0.509388)
0.030000 0.000000 0.030000 ( 0.522662)
user system total real
Getting 68730 Products from Shopify... SKU count 1014322
148.090000 2.970000 151.060000 (3371.578904)
So... that's a wee bit of a stretch there...