scripts.shopify.update_warranty_text ==================================== .. py:module:: scripts.shopify.update_warranty_text .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: scripts.shopify.update_warranty_text.NAMESPACE scripts.shopify.update_warranty_text.KEY scripts.shopify.update_warranty_text.METAFIELD_TYPE scripts.shopify.update_warranty_text.BATCH_SIZE scripts.shopify.update_warranty_text.REQUEST_DELAY_SECONDS scripts.shopify.update_warranty_text.LIST_QUERY scripts.shopify.update_warranty_text.SET_MUTATION Classes ------- .. autoapisummary:: scripts.shopify.update_warranty_text.Product scripts.shopify.update_warranty_text.GraphQL Functions --------- .. autoapisummary:: scripts.shopify.update_warranty_text.list_products scripts.shopify.update_warranty_text.set_warranty scripts.shopify.update_warranty_text.parse_args scripts.shopify.update_warranty_text.main Module Contents --------------- .. py:data:: NAMESPACE :value: 'custom' .. py:data:: KEY :value: 'garantie' .. py:data:: METAFIELD_TYPE :value: 'multi_line_text_field' .. py:data:: BATCH_SIZE :value: 25 .. py:data:: REQUEST_DELAY_SECONDS :value: 0.5 .. py:data:: LIST_QUERY :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ query ProductsWarranty($cursor: String) { products(first: 250, after: $cursor) { nodes { id title metafield(namespace: "custom", key: "garantie") { value } } pageInfo { hasNextPage endCursor } } } """ .. raw:: html
.. py:data:: SET_MUTATION :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ mutation SetWarranty($metafields: [MetafieldsSetInput!]!) { metafieldsSet(metafields: $metafields) { metafields { ownerType } userErrors { field message } } } """ .. raw:: html
.. py:class:: Product .. py:attribute:: id :type: str .. py:attribute:: title :type: str .. py:attribute:: warranty :type: str | None .. py:class:: GraphQL(domain: str, token: str, api_version: str) .. py:attribute:: url .. py:attribute:: token .. py:function:: list_products(graphql: GraphQL) -> list[Product] .. py:function:: set_warranty(graphql: GraphQL, products: collections.abc.Sequence[Product]) -> list[str] Writes WARRANTY_TEXT on ``products`` (one batch); returns the errors. .. py:function:: parse_args(argv: collections.abc.Sequence[str] | None = None) -> argparse.Namespace .. py:function:: main(argv: collections.abc.Sequence[str] | None = None) -> int