Focuses on API authentication, access scopes, and permission management.
Hey guys,
I have a job which runs every day at midnight and retrieves information from etsy.
I need to update my products in shopify but I dont know how to create a valid shopsession.
I could do it with
shop = Shop.find_by(shopify_domain: shop_domain)
Solved! Go to the solution
This is an accepted solution.
Hello,
To create a valid Shopify session, you'll indeed need the shop_domain
. The shop_domain
is a unique identifier for each shop and is necessary to establish a session.
If you're running a job needs to update products on Shopify, you would likely have this information stored somewhere in your database. When a store installs your app, should be storing the shop_domain
in your database.
Here's a general way you could use the shop_domain
to establish a Shopify session in a job:
Shop.find_each do |shop|
shop.with_shopify_session do
# Your code to update products on Shopify goes here
end
end
In this example, Shop.find_each
is iterating over each Shop
record in your database, and for each shop, it establishes a Shopify session and runs the code within the block. If for some reason you don't have the shop_domain
stored, you would need to adjust your app installation process to save this information.
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hello,
To create a valid Shopify session, you'll indeed need the shop_domain
. The shop_domain
is a unique identifier for each shop and is necessary to establish a session.
If you're running a job needs to update products on Shopify, you would likely have this information stored somewhere in your database. When a store installs your app, should be storing the shop_domain
in your database.
Here's a general way you could use the shop_domain
to establish a Shopify session in a job:
Shop.find_each do |shop|
shop.with_shopify_session do
# Your code to update products on Shopify goes here
end
end
In this example, Shop.find_each
is iterating over each Shop
record in your database, and for each shop, it establishes a Shopify session and runs the code within the block. If for some reason you don't have the shop_domain
stored, you would need to adjust your app installation process to save this information.
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Thank you das helps me a lot 🙂