partial implementation of product update

This commit is contained in:
Ben Miller
2024-11-14 02:03:42 -07:00
parent 9b01d6de8a
commit 220ee45e22
5 changed files with 103 additions and 4 deletions

View File

@ -1,5 +1,5 @@
// prettier-ignore
import { Shop, ShopifyProduct, ShopifyProductsQuery, ShopifyProductsResponse } from "./shopifyApi"
import { Shop, ShopifyProduct, ShopifyProductsQuery, ShopifyProductsResponse, ShopifyProductSetInput, ShopifyProductVariant } from "./shopifyApi"
import { getCellRangeByColumnName, getRowByColumnValue } from "./sheetUtils"
@ -87,4 +87,27 @@ export class Product {
this.shopify_id
)
}
ToShopifyProductSet() {
let sps = new ShopifyProductSetInput()
sps.category = this.category
sps.id = this.shopify_id
sps.productType = this.product_type
sps.tags = this.tags
sps.title = this.title
sps.descriptionHtml = this.description
sps.variants = []
let variant = new ShopifyProductVariant()
variant.id = 1
variant.sku = this.sku
variant.price = this.price
variant.weight = this.weight_grams
sps.variants.push(variant)
return sps
}
UpdateShopifyProduct(shop: Shop) {
let sps = this.ToShopifyProductSet()
console.log("sps: " + JSON.stringify(sps))
}
}