From 7510cb03a86319c9509b7fda406cfff5fc04c63d Mon Sep 17 00:00:00 2001 From: GunaTrika Date: Wed, 28 Jul 2021 15:53:54 +0530 Subject: [PATCH] Enabled get all products with sdk. but needs normalizing Added vs code debug script --- .vscode/launch.json | 22 +++++++++++++++++++ .../api/operations/get-all-products.ts | 8 +++++++ 2 files changed, 30 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..0c71d0b98 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Next: Node", + "runtimeExecutable": "${workspaceFolder}/node_modules/next/dist/bin/next", + "env": { + "NODE_OPTIONS": "--inspect" + }, + "port": 9229, + "console": "integratedTerminal" + } + ], + "compounds": [ + { + "name": "Next: Full", + "configurations": ["Next: Node"] + } + ] +} \ No newline at end of file diff --git a/framework/elasticpath/api/operations/get-all-products.ts b/framework/elasticpath/api/operations/get-all-products.ts index 76b1fa036..cd3c01efe 100644 --- a/framework/elasticpath/api/operations/get-all-products.ts +++ b/framework/elasticpath/api/operations/get-all-products.ts @@ -2,8 +2,13 @@ import { Product } from '@commerce/types/product' import { GetAllProductsOperation } from '@commerce/types/product' import type { OperationContext } from '@commerce/api/operations' import type { ElasticpathConfig, Provider } from '../index' +import { gateway as MoltinGateway } from '@moltin/sdk' import data from '../../data.json' +const Moltin = MoltinGateway({ + client_id: process.env.NEXT_PUBLIC_ELASTICPATH_CLIENTID +}) + export default function getAllProductsOperation({ commerce, }: OperationContext) { @@ -17,6 +22,9 @@ export default function getAllProductsOperation({ config?: Partial preview?: boolean } = {}): Promise<{ products: Product[] | any[] }> { + //elastic path get all products + let products = await Moltin.Products.Limit(200).All(); + console.log("All products", products); return { products: data.products, }