You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 6, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 6, 2026. It is now read-only.
AttributeError: product - when I want to create and save a Product #404
I found an issue when I want to do some basic Product creation which is from the sample code.
I think it's caused by the code in /resources/product.py, line 39 when it checks there is any variant in the product or not. if 'variants' in self.product.attributes:
With Python 3.7.5
defmain():
# with the right API_KEY, PASSWORD, SHOP_NAME, API_VERSIONshop_url="https://%s:%s@%s.myshopify.com/admin/api/%s"% (API_KEY, PASSWORD, SHOP_NAME, API_VERSION)
shopify.ShopifyResource.set_site(shop_url)
product=shopify.Product()
product.title="Shopify test title"saved_successfully=product.save()
if__name__=='__main__':
main()
Output with call stack
Traceback (most recent call last):
File "main.py", line 51, in<module>main()
File "main.py", line 42, in main
saved_successfully = product.save()
File "/usr/local/lib/python3.7/site-packages/shopify/resources/product.py", line 39, in save
if'variants'in self.product.attributes:
File "/usr/local/lib/python3.7/site-packages/pyactiveresource/activeresource.py", line 917, in __getattr__
raise AttributeError(name)
AttributeError: product
I fixed this and submitted a pull request (#403). If you want to fix it manually, you can change if 'variants' in self.product.attributes: to if 'variants' in self.attributes: in shopify/resources/product.py.
EDIT: It appears this was already mentioned in #386 and may have caused some other issues, though I have yet to personally experience any.
Activity
smubbs commentedon Aug 11, 2020
#386 Similar issue here
asfakianos commentedon Aug 13, 2020
I fixed this and submitted a pull request (#403). If you want to fix it manually, you can change
if 'variants' in self.product.attributes:toif 'variants' in self.attributes:in shopify/resources/product.py.EDIT: It appears this was already mentioned in #386 and may have caused some other issues, though I have yet to personally experience any.
thecodepixi commentedon May 20, 2021
This appears to have been resolved by a previous PR. Closing as stale. If the issue persists, please feel free to open a new issue on the repo.