misc fixes

*  updateShopifyProductHandler acts on all selected rows
*  updateProductToShopify checks SKU more quickly
*  defaults are always set products
This commit is contained in:
Ben Miller
2024-11-19 21:49:41 -07:00
parent ce0c233dd3
commit 6c7092bc5e
3 changed files with 27 additions and 14 deletions

View File

@ -1,6 +1,6 @@
import { Shop } from "./shopifyApi"
import { Product } from "./Product"
import { toastAndLog } from "./sheetUtils"
import { getCellValueByColumnName, toastAndLog } from "./sheetUtils"
import { getCellRangeByColumnName } from "./sheetUtils"
export function matchProductToShopify(row: number) {
@ -15,19 +15,19 @@ export function matchProductToShopify(row: number) {
export function updateProductToShopify(row: number) {
console.log("row: " + row)
let product = new Product()
let shop = new Shop()
console.log(product)
product.ImportFromInventory(row)
console.log(product)
if (product.sku == "") {
let sheet = SpreadsheetApp.getActive().getSheetByName("product_inventory")
let sku = getCellValueByColumnName(sheet, "sku", row)
console.log("sku: " + sku)
if (sku == "" || sku.match(`\\?`)) {
toastAndLog("No SKU defined for the product on row " + row + "!")
let productInventorySheet =
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("product_inventory")
getCellRangeByColumnName(productInventorySheet, "shopify_id", row).setValue(
getCellRangeByColumnName(sheet, "shopify_id", row).setValue(
""
)
return
}
let product = new Product()
product.ImportFromInventory(row)
console.log(product)
let shop = new Shop()
product.UpdateShopifyProduct(shop)
}