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.