don't try to update if there is no SKU

This commit is contained in:
Ben Miller
2024-11-17 08:18:54 -07:00
parent 5d0ae653fa
commit d6d6af3c44
4 changed files with 27 additions and 6 deletions

View File

@ -1,5 +1,7 @@
import { Shop } from "./shopifyApi"
import { Product } from "./Product"
import { toastAndLog } from "./sheetUtils"
import { getCellRangeByColumnName } from "./sheetUtils"
export function matchProductToShopify(row: number) {
console.log("row: " + row)
@ -18,7 +20,14 @@ export function updateProductToShopify(row: number) {
console.log(product)
product.ImportFromInventory(row)
console.log(product)
product.MatchToShopifyProduct(shop)
console.log(product)
if (product.sku == "") {
toastAndLog("No SKU defined for the product on row " + row + "!")
let productInventorySheet =
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("product_inventory")
getCellRangeByColumnName(productInventorySheet, "shopify_id", row).setValue(
""
)
return
}
product.UpdateShopifyProduct(shop)
}