GithubHelp home page GithubHelp logo

Comments (11)

drwelby avatar drwelby commented on August 22, 2024

Looks like we need to overload the save method to update the prefix_options with the product id:

https://github.com/drwelby/shopify_python_api/blob/master/shopify/resources.py#L115-L117

from shopify_python_api.

drwelby avatar drwelby commented on August 22, 2024

Also a Product.add_variant(variant) seems handy:

https://github.com/drwelby/shopify_python_api/blob/master/shopify/resources.py#L106-L108

from shopify_python_api.

kevinhughes27 avatar kevinhughes27 commented on August 22, 2024

hi there, thanks for opening an issue. I took a look and the way you want to do this is like so
v = shopify.Variant({'product_id':632910392})

I realize this isn't super intuitive but I hope this solves your problem

from shopify_python_api.

drwelby avatar drwelby commented on August 22, 2024

Isn't that the same thing as

v = shopify.Variant()
v.product_id = 632910392

Since in the one-liner you're setting the attribute via pyactiveresource's _update, and in the two-liner via setattr ?

There's been updates to both the python api and pyactiveresource since I filed the pull request, so maybe it's working now anyway? I'll give it a try.

from shopify_python_api.

kevinhughes27 avatar kevinhughes27 commented on August 22, 2024

I would have thought so but it didn't work for me.

from shopify_python_api.

drwelby avatar drwelby commented on August 22, 2024

Seems like the dict you're passing is getting used as prefix_options (where it's needed) and not as the variant's attributes (which is the more intuitive action). No idea why, though.

def __init__(self, attributes=None, prefix_options=None):

( https://github.com/Shopify/pyactiveresource/blob/master/pyactiveresource/activeresource.py#L351)

from shopify_python_api.

kevinhughes27 avatar kevinhughes27 commented on August 22, 2024

yeah that is weird. We're planning to move away from activeresource and pyactiveresource for api libraries eventually.

from shopify_python_api.

drwelby avatar drwelby commented on August 22, 2024

I'll poke around with it more this weekend, but it seems like this would let it work either way:

https://github.com/drwelby/shopify_python_api/blob/master/shopify/resources.py#L119-L122

from shopify_python_api.

kevinhughes27 avatar kevinhughes27 commented on August 22, 2024

That looks like it might be the fix, feel free to make a PR after you play around with it a bit

from shopify_python_api.

drwelby avatar drwelby commented on August 22, 2024

How are you running your unittests? I want to add some additional coverage for my changes but I can't get them to run the way I usually do.

from shopify_python_api.

kevinhughes27 avatar kevinhughes27 commented on August 22, 2024

you can run the tests with
python setup.py test

from shopify_python_api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.