Skip to content

Commit

Permalink
Fix import in PDP metadata generator (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
herzog31 authored Feb 18, 2025
1 parent b281b1f commit 6a51db8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 159 deletions.
162 changes: 6 additions & 156 deletions tools/pdp-metadata/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tools/pdp-metadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
},
"dependencies": {
"he": "^1.2.0",
"xlsx": "^0.18.5"
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
}
}
10 changes: 8 additions & 2 deletions tools/pdp-metadata/pdp-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import fs from 'fs';
import he from 'he';
import productSearchQuery from './queries/products.graphql.js';
import { variantsFragment } from './queries/variants.graphql.js';
import { commerceEndpointWithQueryParams } from "../../scripts/commerce.js";

const basePath = 'https://www.aemshop.net';
const configFile = `${basePath}/configs.json?sheet=prod`;

export async function commerceEndpointWithQueryParams(config) {
const urlWithQueryParams = new URL(config['commerce-endpoint']);
// Set some query parameters for use as a cache-buster. No other purpose.
urlWithQueryParams.searchParams.append('ac-storecode', config['commerce.headers.cs.Magento-Store-Code']);
return urlWithQueryParams;
}

async function performCatalogServiceQuery(config, query, variables) {
const headers = {
'Content-Type': 'application/json',
Expand All @@ -19,7 +25,7 @@ async function performCatalogServiceQuery(config, query, variables) {
'Magento-Website-Code': config['commerce.headers.cs.Magento-Website-Code'],
};

const apiCall = await commerceEndpointWithQueryParams();
const apiCall = await commerceEndpointWithQueryParams(config);

const response = await fetch(apiCall, {
method: 'POST',
Expand Down

0 comments on commit 6a51db8

Please sign in to comment.