Skip to content

Commit

Permalink
upated csv export
Browse files Browse the repository at this point in the history
  • Loading branch information
mikegulline committed Dec 5, 2023
1 parent 480b355 commit c61be1d
Show file tree
Hide file tree
Showing 13 changed files with 743 additions and 1,361 deletions.
1,270 changes: 640 additions & 630 deletions public/csv/ig.csv

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/data/mens-sleeves.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
],
"type": "Sleeves",
"name": "Cotton Long-Sleeve",
"link": "/store/mens/sleeves/block/black",
"image": "/images/products/mens/sleeves/MensSleevesBlockBlack.jpg",
"link": "/store/mens/sleeves/arch/black",
"image": "/images/products/mens/sleeves/MensSleevesArchBlack.jpg",
"has_image_back": true,
"weight": 9.8,
"meta": {
Expand Down
4 changes: 2 additions & 2 deletions public/data/mens-tank.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
],
"type": "Tank",
"name": "Cotton Tank",
"link": "/store/mens/tank/stenciled/black",
"image": "/images/products/mens/tank/MensTankStenciledBlack.jpg",
"link": "/store/mens/tank/block/black",
"image": "/images/products/mens/tank/MensTankBlockBlack.jpg",
"has_image_back": true,
"weight": 5.7,
"meta": {
Expand Down
4 changes: 2 additions & 2 deletions public/data/mens-tee.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
],
"type": "Tee",
"name": "50/50 Tee",
"link": "/store/mens/tee/stenciled/black",
"image": "/images/products/mens/tee/MensTeeStenciledBlack.jpg",
"link": "/store/mens/tee/original/black",
"image": "/images/products/mens/tee/MensTeeOriginalBlack.jpg",
"has_image_back": true,
"weight": 7,
"meta": {
Expand Down
16 changes: 8 additions & 8 deletions public/data/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"subMenu": [
{
"name": "50/50 Tee",
"location": "/store/mens/tee/stenciled/black"
"location": "/store/mens/tee/arch/black"
},
{
"name": "Cotton Tank",
"location": "/store/mens/tank/arch/black"
"location": "/store/mens/tank/block/black"
},
{
"name": "Cotton Long-Sleeve",
"location": "/store/mens/sleeves/stamp/black"
"location": "/store/mens/sleeves/original/black"
}
]
},
Expand All @@ -23,11 +23,11 @@
"subMenu": [
{
"name": "Tri-Blend Tank",
"location": "/store/womens/tank/stamp/gray"
"location": "/store/womens/tank/arch/gray"
},
{
"name": "Cotton Oversized Crop",
"location": "/store/womens/oversized-crop/block/black"
"location": "/store/womens/oversized-crop/small-circle/black"
}
]
},
Expand All @@ -41,15 +41,15 @@
},
{
"name": "Cotton Crew",
"location": "/store/outerwear/crew/block/black"
"location": "/store/outerwear/crew/arch/black"
},
{
"name": "50/50 Hoodie",
"location": "/store/outerwear/50-50-hoodie/arch/black"
"location": "/store/outerwear/50-50-hoodie/block/black"
},
{
"name": "Cotton Hoodie",
"location": "/store/outerwear/hoodie/stenciled/black"
"location": "/store/outerwear/hoodie/stamp/black"
},
{
"name": "Knit Beanie",
Expand Down
4 changes: 2 additions & 2 deletions public/data/outerwear-50-50-crew.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
],
"type": "50-50-Crew",
"name": "50/50 Crew",
"link": "/store/outerwear/50-50-crew/block/black",
"image": "/images/products/outerwear/50-50-crew/Outerwear50-50-CrewBlockBlack.jpg",
"link": "/store/outerwear/50-50-crew/stenciled/black",
"image": "/images/products/outerwear/50-50-crew/Outerwear50-50-CrewStenciledBlack.jpg",
"has_image_back": true,
"weight": 34.3,
"meta": {
Expand Down
4 changes: 2 additions & 2 deletions public/data/outerwear-crew.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
],
"type": "Crew",
"name": "Cotton Crew",
"link": "/store/outerwear/crew/stenciled/black",
"image": "/images/products/outerwear/crew/OuterwearCrewStenciledBlack.jpg",
"link": "/store/outerwear/crew/stamp/black",
"image": "/images/products/outerwear/crew/OuterwearCrewStampBlack.jpg",
"has_image_back": true,
"weight": 34.3,
"meta": {
Expand Down
4 changes: 2 additions & 2 deletions public/data/outerwear-hoodie.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
],
"type": "Hoodie",
"name": "Cotton Hoodie",
"link": "/store/outerwear/hoodie/block/black",
"image": "/images/products/outerwear/hoodie/OuterwearHoodieBlockBlack.jpg",
"link": "/store/outerwear/hoodie/stenciled/black",
"image": "/images/products/outerwear/hoodie/OuterwearHoodieStenciledBlack.jpg",
"has_image_back": false,
"weight": 34.3,
"meta": {
Expand Down
48 changes: 24 additions & 24 deletions public/data/store-new.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
{
"name": "50/50 Tee",
"type": "Tee",
"link": "/store/mens/tee/stenciled/black",
"image": "/images/products/mens/tee/MensTeeStenciledBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/AOvr7qinrbKwtv7+/wDLy9BFRExEQknAwMQA29veDgwWBgMQ6OjrAOzs8IKBh359gvf2+TAsHm9KhdxaAAAAAElFTkSuQmCC",
"link": "/store/mens/tee/arch/black",
"image": "/images/products/mens/tee/MensTeeArchBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/AObm656en5aWltnY2AC9vsFHR0lRT065ubkA8vL0EQ8OBQEA2NjYAPv7/3Jycm5tauPj4wKnHNcXE1ghAAAAAElFTkSuQmCC",
"logos": [
{
"logo": "Small Circle",
Expand Down Expand Up @@ -105,9 +105,9 @@
{
"name": "Cotton Tank",
"type": "Tank",
"link": "/store/mens/tank/arch/black",
"image": "/images/products/mens/tank/MensTankArchBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/APv6/ZiboZ+hp/39/wDV1dYxMTdDRUrd3d8AsrK0BAMLFxcZvb2/AMbGyExMTlZWVs7O0Q6oG35NAdZZAAAAAElFTkSuQmCC",
"link": "/store/mens/tank/block/black",
"image": "/images/products/mens/tank/MensTankBlockBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/APv7/4aJj4+SmPv7/wDIys0iIygtLjfS0tYAqquuAgEKCAgOo6SnAMLCxDY4PD9AQcXFyNlPGTpp0Ej9AAAAAElFTkSuQmCC",
"logos": [
{
"logo": "Small Circle",
Expand Down Expand Up @@ -154,9 +154,9 @@
{
"name": "Cotton Long-Sleeve",
"type": "Sleeves",
"link": "/store/mens/sleeves/stamp/black",
"image": "/images/products/mens/sleeves/MensSleevesStampBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/AP39/5eanZCSlPHx8gC5ubk/Pz5ERETEw8MAwsLCAAAAAwEAxcTDAObm521tb3l4duPi4viOG++gk2WFAAAAAElFTkSuQmCC",
"link": "/store/mens/sleeves/original/black",
"image": "/images/products/mens/sleeves/MensSleevesOriginalBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/APv7/aKnraeqsP79/wC9vLwvMjc5O0HNzc0Ara2qAAAABQMAxMLAAMPDw1RUVF9cVtfV0v+CGvRxttd1AAAAAElFTkSuQmCC",
"logos": [
{
"logo": "Small Circle",
Expand Down Expand Up @@ -240,9 +240,9 @@
{
"name": "Tri-Blend Tank",
"type": "Tank",
"link": "/store/womens/tank/stamp/gray",
"image": "/images/products/womens/tank/WomensTankStampGray.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/AP7+/5WVmKSkpvz8/wDr6+4nJCQ7NjTy8vUAtLS2EQAAGQUAtrOzAMPDxTw3NEY/O8fGxwxKGsNcuPiXAAAAAElFTkSuQmCC",
"link": "/store/womens/tank/arch/gray",
"image": "/images/products/womens/tank/WomensTankArchGray.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/AP39/5+fo56eoPr6/QDs7O48ODRAOzjm5ecAr62vEgAAGwsAqqenAMDAwElFQTkzLba0tg8/Gn4yMVIRAAAAAElFTkSuQmCC",
"logos": [
{
"logo": "Small Circle",
Expand Down Expand Up @@ -310,9 +310,9 @@
{
"name": "Cotton Oversized Crop",
"type": "Oversized-Crop",
"link": "/store/womens/oversized-crop/block/black",
"image": "/images/products/womens/oversized-crop/WomensOversized-CropBlockBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/APz7/+fn6ujp6/v7/wCFh44tLjUsLTOMjpQAoaKnAgQODhAWo6SnAPf3+Ovr7u/v8vn5+y3mH0vAiFdgAAAAAElFTkSuQmCC",
"link": "/store/womens/oversized-crop/small-circle/black",
"image": "/images/products/womens/oversized-crop/WomensOversized-CropSmallCircleBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/AP7+//Hz9PDy8/39/wCvrK1INDhJODusq68AtbS1IwAAJQAFsrK0APr6/dLV1dfY2Pn3+mMSIIGLCfhqAAAAAElFTkSuQmCC",
"logos": [
{
"logo": "Small Circle",
Expand Down Expand Up @@ -453,9 +453,9 @@
{
"name": "Cotton Crew",
"type": "Crew",
"link": "/store/outerwear/crew/block/black",
"image": "/images/products/outerwear/crew/OuterwearCrewBlockBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/APn5/L2+xLq8wvb3+gCSlp8qLTc8PUaMkJgAjZGZAgMRAAAKeHmBAPz8/7m7vq+vtO/v8fNoHGgWpJMwAAAAAElFTkSuQmCC",
"link": "/store/outerwear/crew/arch/black",
"image": "/images/products/outerwear/crew/OuterwearCrewArchBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/APr6/L2+wrq7wPb2+gCUlp4hJCkoKC6QkJUAj5KXDQ0RBAMHent+APz8/76+wLS1uO/v8endHDkxN8G0AAAAAElFTkSuQmCC",
"logos": [
{
"logo": "Original",
Expand Down Expand Up @@ -531,9 +531,9 @@
{
"name": "50/50 Hoodie",
"type": "50-50-Hoodie",
"link": "/store/outerwear/50-50-hoodie/arch/black",
"image": "/images/products/outerwear/50-50-hoodie/Outerwear50-50-HoodieArchBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/AP7//7Ktrby5uf///wDQzdE/OTpGQEHR0NEAhoWHDQgNBAMGbm1xAN/e32xmZmFeX8XFxwvpGt10mxVoAAAAAElFTkSuQmCC",
"link": "/store/outerwear/50-50-hoodie/block/black",
"image": "/images/products/outerwear/50-50-hoodie/Outerwear50-50-HoodieBlockBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/AP7//6+rqrq2t////wDNy85DPD1GQEHOzdAAgoGCEQ0QBQEHamlsAN7d32ZgYF5aW8TExQbEGpglmoRZAAAAAElFTkSuQmCC",
"logos": [
{
"logo": "Original",
Expand Down Expand Up @@ -579,9 +579,9 @@
{
"name": "Cotton Hoodie",
"type": "Hoodie",
"link": "/store/outerwear/hoodie/stenciled/black",
"image": "/images/products/outerwear/hoodie/OuterwearHoodieStenciledBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/APv7/cjHx8XFxf39/wDX19hiWlVWTkjBv78ApKOiHhIGDwAAfXd2AOLi4395d3JwbM7LzDsFHLWcgSh2AAAAAElFTkSuQmCC",
"link": "/store/outerwear/hoodie/stamp/black",
"image": "/images/products/outerwear/hoodie/OuterwearHoodieStampBlack.jpg",
"imageBlur": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAP0lEQVR4nAE0AMv/APv7/cnHyMfGx/z9/wDY2NpcVE9PRkDCwcEApqOjHhMHDwAAf3h3AOPj5IF6eHdxbc/LzTkjHLQJXHySAAAAAElFTkSuQmCC",
"logos": [
{
"logo": "Original",
Expand Down
4 changes: 2 additions & 2 deletions public/data/womens-oversized-crop.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
],
"type": "Oversized-Crop",
"name": "Cotton Oversized Crop",
"link": "/store/womens/oversized-crop/stenciled/black",
"image": "/images/products/womens/oversized-crop/WomensOversized-CropStenciledBlack.jpg",
"link": "/store/womens/oversized-crop/arch/black",
"image": "/images/products/womens/oversized-crop/WomensOversized-CropArchBlack.jpg",
"has_image_back": true,
"weight": 2.9,
"meta": {
Expand Down
4 changes: 2 additions & 2 deletions public/data/womens-tank.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
],
"type": "Tank",
"name": "Tri-Blend Tank",
"link": "/store/womens/tank/stamp/gray",
"image": "/images/products/womens/tank/WomensTankStampGray.jpg",
"link": "/store/womens/tank/original/gray",
"image": "/images/products/womens/tank/WomensTankOriginalGray.jpg",
"has_image_back": true,
"weight": 2.6,
"meta": {
Expand Down
89 changes: 55 additions & 34 deletions scripts/products/ig-csv.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const path = require('path');
const fs = require('fs');
const store = require('./store');
const { kebab } = require('./models.js');

const getLink = (baseUrl, category, type, logo, color) =>
`${baseUrl}store/${category}/${type}/${logo}/${color}`.toLowerCase();
`${baseUrl}store/${category}/${kebab(type)}/${kebab(logo)}/${kebab(
color
)}`.toLowerCase();

const getImageLink = (baseUrl, category, type, logo, color) =>
`${baseUrl}images/products/${category}/${type}/`.toLowerCase() +
`${category}${type}${logo}${color}.jpg`.replace(/ /g, '-');
`${baseUrl}images/products/${category}/${kebab(type)}/`.toLowerCase() +
`${category}${type}${logo}${color}.jpg`.replace(/ /g, '');

const getTitle = (product, logo, color, size) =>
`${product} With ${logo} Design (${color}) ${size}`;
Expand All @@ -31,39 +34,57 @@ const getGender = (type) => {
const fileOutput = [];
const baseUrl = 'https://www.loyaltofew.com/';
store.map(({ name: category, products }) => {
products.map(({ product, type, weight, meta, logos, colors, sizes }) => {
logos.map((logo) => {
colors.map((color) => {
sizes.map(({ size, price }) => {
const { description } = meta;
const item_group_id = getGroupId(category, type, logo, color);
const id = getId(category, type, logo, color, size);
const title = getTitle(product, logo, color, size);
const link = getLink(baseUrl, category, type, logo, color);
const image_link = getImageLink(baseUrl, category, type, logo, color);
const gender = getGender(type);
const build = {
item_group_id,
id,
title,
description: description.replace(/,/g, ','),
availability: 'in stock',
condition: 'new',
price: `${price} USD`,
link,
image_link,
brand: 'Loyal to Few®',
gender,
color,
size,
age_group: 'adult',
shipping_weight: weight,
};
fileOutput.push(build);
products.map(
({ product, type, weight, meta, logos, colors, colorsAlt, sizes }) => {
logos.map((logo) => {
colors.map((color) => {
sizes.map(({ size, price, ...rest }) => {
const { description } = meta;
const item_group_id = getGroupId(category, type, logo, color);
const id = getId(category, type, logo, color, size);
const title = getTitle(product, logo, color, size);
const link = getLink(baseUrl, category, type, logo, color);
const image_link = getImageLink(
baseUrl,
category,
type,
logo,
color
);
const gender = getGender(type);
const build = {
item_group_id,
id,
title,
description: description.replace(/,/g, ','),
availability: 'in stock',
condition: 'new',
price: `${price} USD`,
link,
image_link,
brand: 'Loyal to Few®',
gender,
color,
size,
age_group: 'adult',
shipping_weight: weight,
};
if (rest?.colors && !rest.colors.includes(color)) {
console.log('skip', id);
} else if (
colorsAlt &&
colorsAlt[logo] &&
!colorsAlt[logo].includes(color)
) {
console.log('2nd skip', id);
} else {
fileOutput.push(build);
}
});
});
});
});
});
}
);
});

const csvKeys = Object.keys(fileOutput[0]).join(', ') + '\n';
Expand Down
Loading

1 comment on commit c61be1d

@vercel
Copy link

@vercel vercel bot commented on c61be1d Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.