slince / shopify-api-php

:rocket: Shopify API Client for PHP
MIT License
128 stars 48 forks source link

List of Collects for one product #17

Closed nitromedia closed 5 years ago

nitromedia commented 5 years ago

So i'm trying to use your API Client to list all the collections related to a product.

According to the docs of Shopify it should be done like this : GET admin/collects.json?product_id=XXXXXXX

I tried a couple of methods from the manager, but nothing seems to work.

$collect = $client->getCollectManager()->find(XXXXXX); (don't work) $collect = $client->get('collects.json?product_id=XXXXXX'); (list results, but not the one i'm expecting)

slince commented 5 years ago

Method find is used to get one entity by its id;

if you want get entity collection, you should use findAll":

$collects = $client->getCollectManager()->findAll(['product_id' => xxx]);

$collects is a collection of Collect

if you want to get raw data;

 $collects = $client->get('collects', ['product_id' => xxx]);

print_r($collects);

argument 1 is a resource identiter;

there is a example about product in README.md; you can reference it

nitromedia commented 5 years ago

Thank you very much !!! So simple ;)

Also there seems to be nothing about inventory Level, will it be added eventually ?

slince commented 5 years ago

Also there seems to be nothing about inventory Level, will it be added eventually ?

is there a help doc url?

nitromedia commented 5 years ago

https://help.shopify.com/en/api/reference/inventory

slince commented 5 years ago

see 2.2.0