From dbc3cd3141862824a65356f66eed4974ab3dfad2 Mon Sep 17 00:00:00 2001 From: Isaaz Garcia Date: Mon, 11 Apr 2022 07:42:34 -0700 Subject: [PATCH 1/3] adding collections --- README.md | 13 +++++++++++++ composer.json | 1 + src/controllers/FeedsController.php | 9 +++++++++ src/services/ShopifyAdminApi.php | 20 ++++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/README.md b/README.md index 4260e4e..da2154d 100644 --- a/README.md +++ b/README.md @@ -52,3 +52,16 @@ Set up FeedMe to query either of the following routes. We're only exposing a mi }, ] ``` + +#### Collections + +`https://cms-domain.com/actions/importable-shopify-feeds/feeds/collections` + +```json +[ + { + "title": "Collection Title", + "handle": "collection-title" + }, +] +``` diff --git a/composer.json b/composer.json index 0cdcd5d..3a6ffff 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "name": "bkwld/craft-importable-shopify-feeds", "description": "A Craft plugin that maps Shopify data into feeds that are more easily consumed by FeedMe.", "type": "craft-plugin", + "version": "1.0.1", "license": "MIT", "authors": [ { diff --git a/src/controllers/FeedsController.php b/src/controllers/FeedsController.php index 594e973..6310f5e 100644 --- a/src/controllers/FeedsController.php +++ b/src/controllers/FeedsController.php @@ -29,5 +29,14 @@ public function actionVariants(): Response return $this->asJson($variants); } + /** + * Get all collections + */ + public function actionCollections(): Response + { + $collections = Plugin::getInstance()->shopifyAdminApi->getCollections(); + return $this->asJson($collections); + } + } diff --git a/src/services/ShopifyAdminApi.php b/src/services/ShopifyAdminApi.php index e46e46a..6bb2375 100644 --- a/src/services/ShopifyAdminApi.php +++ b/src/services/ShopifyAdminApi.php @@ -100,6 +100,26 @@ public function getVariants() }, $variants); } + /** + * Get all products + */ + public function getCollections() + { + $response = $this->execute([ + 'query' => '{ + collections(first:250) { + edges { + node { + title + handle + } + } + } + }' + ]); + return $this->flattenEdges($response)['collections']; + } + /** * Flatten edges arrays */ From dba0650f24f1d2ec44707a4505c1a36d41964477 Mon Sep 17 00:00:00 2001 From: Isaaz Garcia Date: Mon, 11 Apr 2022 07:44:18 -0700 Subject: [PATCH 2/3] updating comment --- src/services/ShopifyAdminApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/ShopifyAdminApi.php b/src/services/ShopifyAdminApi.php index 6bb2375..f6639fd 100644 --- a/src/services/ShopifyAdminApi.php +++ b/src/services/ShopifyAdminApi.php @@ -101,7 +101,7 @@ public function getVariants() } /** - * Get all products + * Get all collections */ public function getCollections() { From 6af101f1303b8180b266cd81f7876dc00a899a95 Mon Sep 17 00:00:00 2001 From: Isaaz Garcia Date: Mon, 11 Apr 2022 07:45:26 -0700 Subject: [PATCH 3/3] updating version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3a6ffff..bd57cc6 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "bkwld/craft-importable-shopify-feeds", "description": "A Craft plugin that maps Shopify data into feeds that are more easily consumed by FeedMe.", "type": "craft-plugin", - "version": "1.0.1", + "version": "1.2.0", "license": "MIT", "authors": [ {