scripts.shopify.update_warranty_text¶
Rewrites the custom.garantie metafield of every Shopify product
already online with the current WARRANTY_TEXT.
uv run python -m scripts.shopify.update_warranty_text (or make
update-warranty-text). New products get the text from
create_product_shopify and update_product re-syncs it, but products
nobody touches since the text changed keep the old one – this fixes those
in one pass.
Unlike the other scripts here this imports from api: the text must be
exactly the one the API writes, or the next update_product run would
rewrite it again.
Only products that already have a garantie metafield are touched (the
ones created by the pipeline); products without one are listed, not
modified. Products already holding the current text are skipped, so a rerun
is a no-op. Prints a plan and asks for a typed confirmation before writing
anything, unless --yes is given; --dry-run only prints the plan.
Attributes¶
Classes¶
Functions¶
|
|
|
Writes WARRANTY_TEXT on |
|
|
|
Module Contents¶
- scripts.shopify.update_warranty_text.NAMESPACE = 'custom'¶
- scripts.shopify.update_warranty_text.KEY = 'garantie'¶
- scripts.shopify.update_warranty_text.METAFIELD_TYPE = 'multi_line_text_field'¶
- scripts.shopify.update_warranty_text.BATCH_SIZE = 25¶
- scripts.shopify.update_warranty_text.REQUEST_DELAY_SECONDS = 0.5¶
- scripts.shopify.update_warranty_text.LIST_QUERY = Multiline-String¶
Show Value
""" query ProductsWarranty($cursor: String) { products(first: 250, after: $cursor) { nodes { id title metafield(namespace: "custom", key: "garantie") { value } } pageInfo { hasNextPage endCursor } } } """
- scripts.shopify.update_warranty_text.SET_MUTATION = Multiline-String¶
Show Value
""" mutation SetWarranty($metafields: [MetafieldsSetInput!]!) { metafieldsSet(metafields: $metafields) { metafields { ownerType } userErrors { field message } } } """
- class scripts.shopify.update_warranty_text.GraphQL(domain: str, token: str, api_version: str)¶
- url¶
- token¶
- scripts.shopify.update_warranty_text.set_warranty(graphql: GraphQL, products: collections.abc.Sequence[Product]) list[str]¶
Writes WARRANTY_TEXT on
products(one batch); returns the errors.
- scripts.shopify.update_warranty_text.parse_args(argv: collections.abc.Sequence[str] | None = None) argparse.Namespace¶
- scripts.shopify.update_warranty_text.main(argv: collections.abc.Sequence[str] | None = None) int¶