misc fixes
* updateShopifyProductHandler acts on all selected rows * updateProductToShopify checks SKU more quickly * defaults are always set products
This commit is contained in:
20
src/match.ts
20
src/match.ts
@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user