Skip to content

Commit

Permalink
Remove launchpad cats
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinhenderson committed Apr 12, 2024
1 parent bac11e4 commit 520dcab
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions lib/products/get-all-categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { request } from "../data-fetching";

import config from "../config";
import { getMediaNode } from "../utils/get-media-node";
import { getLaunchpadCategories } from "../launchpad";

const ENDPOINT = `${config.baseUrl}/graphql`;

Expand Down Expand Up @@ -86,42 +85,9 @@ export const getAllProductCategories = async () => {
const queryResponse = await request(ENDPOINT, GetAllProductCategories);
const categories = queryResponse.productCategories.nodes;

const wooProductCategories = parseCategories(categories);

const launchpadItems = await getLaunchpadCategories();

for (const currentItem of launchpadItems) {
const mainCategory = wooProductCategories.find(
(x) => x.slug === currentItem.templateCategorySlug
);

mainCategory.productCount = mainCategory.productCount + 1;
mainCategory.productSlugs = [
currentItem.templateId,
...mainCategory.productSlugs,
];

if (!mainCategory) continue;
console.log(categories.map((x) => x.slug));

const subcategory = mainCategory.subcategories.find(
(x) => x.slug === currentItem.templateSubcategorySlug
);

if (!subcategory) {
mainCategory.subcategories.push({
productSlugs: [currentItem.templateId],
name: currentItem.templateSubcategory,
slug: currentItem.templateSubcategorySlug,
productCount: 1,
});
} else {
subcategory.productCount = subcategory.productCount + 1;
subcategory.productSlugs = [
currentItem.templateId,
...subcategory.productSlugs,
];
}
}
const wooProductCategories = parseCategories(categories);

return wooProductCategories;
};
Expand Down

0 comments on commit 520dcab

Please sign in to comment.