partial implementation of product update
This commit is contained in:
@ -625,7 +625,7 @@ export class ShopifyProduct {
|
||||
template_suffix: string
|
||||
title: string
|
||||
updated_at: Date
|
||||
variants: ProductVariant[]
|
||||
variants: ShopifyProductVariant[]
|
||||
vendor: string
|
||||
}
|
||||
|
||||
@ -649,7 +649,7 @@ class ProductOption {
|
||||
values: string[]
|
||||
}
|
||||
|
||||
class ProductVariant {
|
||||
export class ShopifyProductVariant {
|
||||
barcode: string
|
||||
compare_at_price: number
|
||||
created_at: Date
|
||||
@ -735,6 +735,57 @@ export class ShopifyProductsResponse {
|
||||
}
|
||||
}
|
||||
|
||||
export class ShopifyProductSetQuery {
|
||||
GQL: string
|
||||
JSON: JSON
|
||||
constructor(
|
||||
query: string = "",
|
||||
fields: string[] = ["id", "title", "handle"],
|
||||
cursor: string = "",
|
||||
pageSize: number = 10
|
||||
) {
|
||||
let cursorText: string
|
||||
if (cursor == "") {
|
||||
cursorText = ""
|
||||
} else {
|
||||
cursorText = `, after: "${cursor}"`
|
||||
}
|
||||
let queryText: string
|
||||
if (query == "") {
|
||||
queryText = ""
|
||||
} else {
|
||||
queryText = `, query: "${query}"`
|
||||
}
|
||||
this.GQL = `{
|
||||
products(first: ${pageSize}${cursorText}${queryText}) {
|
||||
edges {
|
||||
node { ${fields.join(" ")} }
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
endCursor
|
||||
}
|
||||
}
|
||||
}`
|
||||
let j = `{"query": ${formatGqlForJSON(this.GQL)}}`
|
||||
console.log(j)
|
||||
this.JSON = JSON.parse(j)
|
||||
}
|
||||
}
|
||||
|
||||
export class ShopifyProductSetInput {
|
||||
category: string
|
||||
descriptionHtml: string
|
||||
id: string
|
||||
productType: string
|
||||
redirectNewHandle: boolean = true
|
||||
status: string = "DRAFT"
|
||||
tags: string
|
||||
title: string
|
||||
variants: ShopifyProductVariant[]
|
||||
vendor: string
|
||||
}
|
||||
|
||||
function formatGqlForJSON(gql: string) {
|
||||
let singleLine = gql.split("\n").join(" ").replace(/\s+/g, " ")
|
||||
return JSON.stringify(singleLine)
|
||||
|
||||
Reference in New Issue
Block a user