* updateShopifyProductHandler acts on all selected rows * updateProductToShopify checks SKU more quickly * defaults are always set products
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { Shop } from "./shopifyApi"
|
|
import { Product } from "./Product"
|
|
import { getCellValueByColumnName, toastAndLog } from "./sheetUtils"
|
|
import { getCellRangeByColumnName } from "./sheetUtils"
|
|
|
|
export function matchProductToShopify(row: number) {
|
|
console.log("row: " + row)
|
|
let product = new Product()
|
|
console.log(product)
|
|
product.ImportFromInventory(row)
|
|
console.log(product)
|
|
product.MatchToShopifyProduct(new Shop())
|
|
console.log(product)
|
|
}
|
|
|
|
export function updateProductToShopify(row: number) {
|
|
console.log("row: " + row)
|
|
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 + "!")
|
|
getCellRangeByColumnName(sheet, "shopify_id", row).setValue(
|
|
""
|
|
)
|
|
return
|
|
}
|
|
let product = new Product()
|
|
product.ImportFromInventory(row)
|
|
console.log(product)
|
|
let shop = new Shop()
|
|
product.UpdateShopifyProduct(shop)
|
|
} |