Closed lurch closed 7 years ago
What do you suggest... perhaps index by product_id ? Does that do it? On 19 May 2016 15:38, "Andrew Scheller" notifications@github.com wrote:
https://shop.pimoroni.com/collections/pi-zero/products/raspberry-pi-zero.json contains:
{"id":16715869959,"product_id":3580233095,"title":"Pi Zero + Project Kit","price":"0.00","sku":"\/pi-zero-project-kits","position":2,"grams":400,"inventory_policy":"deny","compare_at_price":null,"fulfillment_service":"manual","inventory_management":null,"option1":"Pi Zero + Project Kit","option2":null,"option3":null,"created_at":"2016-02-27T09:03:36+00:00","updated_at":"2016-02-28T16:15:33+00:00","taxable":true,"barcode":"","image_id":null,"inventory_quantity":1,"weight":0.4,"weight_unit":"kg","old_inventory_quantity":1,"requires_shipping":true},
which isn't actually a "real" product, but (AFAICT) is simply used to create the "View options" button on https://shop.pimoroni.com/collections/pi-zero/products/raspberry-pi-zero And therefore http://stockalert.alexellis.io/ reports one more than is actually available.
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/alexellis/pi_zero_stock/issues/4
Dunno - I noticed that in the JSON snippet above the price is 0.00
and the barcode is ""
which isn't true for the other products in https://shop.pimoroni.com/collections/pi-zero/products/raspberry-pi-zero.json but I dunno if they're reliable indicators.
Ping @Gadgetoid ;-)
Phil, these are the URLs I'm pulling - then I look at inventory_quantity for each variant and sum it up.
https://shop.pimoroni.com/products/pi-zero-complete-starter-kit.js https://shop.pimoroni.com/products/pi-zero-project-kits.js https://shop.pimoroni.com/products/raspberry-pi-zero.js
Don't know whether I can use a key on 'variant type' or 'variant id' etc to make sure I don't re-count the single unit @lurch mentioned.
@lurch had a quick chat with Phil, he won't get notifications from @Gagetoid since he's not on the repo, but I think I can look for a '/' in placeholder products. For now I'm excluding price of 0 and it works.
i.e. "sku":"\/
https://github.com/alexellis/pi_zero_stock/commit/f6d0bdcc5d526a00323f1fb8d5331f7a847bc318
Thank you for taking the time to help with the project. :+1:
We do crazy, horrible things to Shopify to build the front-end pages that we want/need. One thing in particular is using variants to soft-link out to other products. This is all resolved in the front-end template code cleanly, but the JSON feed has no concept of the mad trickery we're employing.
Any variant looking like this: "sku": "\/pi-zero-project-kits",
or "sku": "PIM140\/pi-zero-complete-starter-kit",
, IE containing a forward slash, will never be shown to the user, and instead denotes a link to another product. In fact it's the handle of the product it's linking to.
They are given a stock of 1 to indicate that the linked product is in stock at all, I suspect, although whether this is completely necessary would require some tinkering and fudging with code we probably don't want to upset :D
+1 for @lurch cropping up again on yet another Pi-related project. He's super awesome ;)
@Gadgetoid - super smooth bilge tank and release of the product. Did you guys check out/use the site at all Mon/Tues etc?
OK to close @lurch ?
Well, from what Phil says looking for the \/ in the SKU would be more reliable?
In fact, I wonder if you could just start from https://shop.pimoroni.com/products/raspberry-pi-zero.js and then find the "sku":"PIM140\/pi-zero-complete-starter-kit"
and "sku":"\/pi-zero-project-kits"
and (in the code) automatically deduce that you need to check https://shop.pimoroni.com/products/pi-zero-complete-starter-kit.js and https://shop.pimoroni.com/products/pi-zero-project-kits.js as well? (which I guess would mean making the code recursive)
@Gadgetoid I notice there's a .js and .json for each of the URLs i.e. https://shop.pimoroni.com/products/raspberry-pi-zero.js and https://shop.pimoroni.com/products/raspberry-pi-zero.json - which would it be better for @alexellis to be checking, or doesn't it matter?
...but of course this is entirely your project, so if you're happy with your current solution then feel free to close this issue! :-)
I'm OK with this for now, may keep this open as an enhancement.
https://shop.pimoroni.com/collections/pi-zero/products/raspberry-pi-zero.json contains:
{"id":16715869959,"product_id":3580233095,"title":"Pi Zero + Project Kit","price":"0.00","sku":"\/pi-zero-project-kits","position":2,"grams":400,"inventory_policy":"deny","compare_at_price":null,"fulfillment_service":"manual","inventory_management":null,"option1":"Pi Zero + Project Kit","option2":null,"option3":null,"created_at":"2016-02-27T09:03:36+00:00","updated_at":"2016-02-28T16:15:33+00:00","taxable":true,"barcode":"","image_id":null,"inventory_quantity":1,"weight":0.4,"weight_unit":"kg","old_inventory_quantity":1,"requires_shipping":true},
which isn't actually a "real" product, but (AFAICT) is simply used to create the "View options" button on https://shop.pimoroni.com/collections/pi-zero/products/raspberry-pi-zero And therefore http://stockalert.alexellis.io/ reports one more than is actually available.