Shopify / Shopify/shopify_python_api

Save many metafields with a single request

Open
#112 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
Python
Stars
1.4k
Forks
388
Avg merge
5h 39m
Merged PRs (30d)
1

Description

There does not seem to be a way to attach metafields locally, and then simply save the product with the metafields along with it. I'm forced to use add_metafields() or Metafield().save(), both of which adds a single metafield per API call. This is very slow.

If I take a product with 50 metafields, and save it as a new product, it saves almost instantly, like so:

p = shopify.Product.find()[0]
print len(p.metafields())
> 50
p.id = None
p.images = None
p.save()

How can I attach metafields to a product in the same way they are attached when they are fetched?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Product.save(), add_metafields(), and Metafield().save() to understand how fetched metafields are represented and persisted. The work is done when locally attached metafields can be saved with a new product in one API request, with coverage for the reported multi-metafield case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.