Product Response Python API

Highlighted
New Member
4 0 0

Hi team,

 

I've been using the shopify_python_api with much success as I extend the functionality of an existing ERP site to manage our Shopify site. 

 

I'm having lots of trouble with the Product API but in a very weird case. One particular product save attempt is returning a response that doesn't make sense and I'm not sure why. It seems to always happen with this product only and I'm not sure if I'm doing something wrong or if the response is bad and something else is going on entirely.

 

ipdb> from pprint import pprint
ipdb> product = shopify.Product()
ipdb> product.body_html = obj.description
ipdb> product.options = [{
            'name': v.name,
            'values': [o for o in v.variantoption_set.all().values_list('name', flat=True)]
        } for v in obj.variant_set.annotate(num_vo=Count('variantoption')).filter(num_vo__gt=0)]
ipdb> product.title = obj.name
ipdb> product.variants = []
ipdb> pprint(product.__dict__)
{'_initialized': True,
 '_prefix_options': {},
 'attributes': {'body_html': '',
                'options': [{'name': 'Unit', 'values': ['1 Pint']},
                            {'name': 'Flavor',
                             'values': ['Caramel Cookie Crunch',
                                        'Americone Dream',
                                        'The Tonight Dough',
                                        'Chocolate Fudge Brownie',
                                        'Half Baked',
                                        'Chocolate Chip Cookie Dough']}],
                'title': "Ben & Jerry's Ice Cream",
                'variants': []},
 'errors': <pyactiveresource.activeresource.Errors object at 0x1123e3110>,
 'klass': <class 'shopify.resources.product.Product'>}
ipdb> product.save()
False
ipdb> product.errors.errors
{'base': ['You need to add option values for Flavor']}

I clearly have option values for Flavor just as I do for Unit so this error doesn't make any sense unless I'm missing something.

 

Original Github Issue: https://github.com/Shopify/shopify_python_api/issues/385

0 Likes
New Member
4 0 0

UPDATE: This is happening with all my products with multiple variants. even though all variants have options.

0 Likes