zf-fr/zfr-shopify

product collections and collection products arrays?

Closed this issue · 2 comments

The Shopify API documentation lists methods for retrieving the array of products pointed to by a collection (collection.products) and the collections associated with any given product (product.collections)

Is there any way to retrieve these with this API? I tried:

$foo = $shopifyClient->getProduct(array('id' => $productId, 'fields' => 'collections'));

Hi,

The REST API will not allow you to do that. If you want to be able to get a product with collections in one API call, you will need to explore the GraphQL API (for which ZfrShopify has a basic support : https://github.com/zf-fr/zfr-shopify#graphql-api)

OK, I think I figured it out:

$shopifyClient->getSmartCollections(['product_id' => $productId]);
or
$shopifyClient->getProducts(['collection_id' => $collectionId]);

(so yes, it does allow you to do that)