Last active
March 17, 2017 05:04
-
-
Save Rolilink/bbab88e90139938dfab9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Saving a product from database | |
product = ShopifyAPI::Product.find(179761209) # This does an get http request to shopify api | |
db_product = DBProduct.new # You have to create a new rails model | |
db_product.shopify_id = product.id | |
db_product.save | |
# Saving a product to shopify | |
product.title = 'changed' | |
product.save # updates product in shopify, http put request | |
#Fetching the saved product in the database from shopify | |
product_from_db = DBProduct.all.first | |
shopify_product = ShopifyAPI::Product.find(product_from_db.shopidy_id) # This does an get http request to shopify api with the id you saved in the database | |
# Creating a product in shopify | |
product = ShopifyAPI::Product.create({attrs..}) # just give it a hash with the required attributes | |
#Another way | |
product = ShopifyAPI::Product.new | |
product.title = 'shoes' | |
product.description = 'this is a shoe' | |
product.save # here it does an http request not a database one, if you want to save into database create a new model to save this information |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment