-
-
Save CodeBrotha/e3e74e87014a83b28ae4e83a710e4a8d 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