Is there any other way other than webhooks to sync shopify products to Ruby on Rails application?

Is there any other way other than webhooks to sync shopify products to Ruby on Rails application?

ankitaagrawal-k
New Member
4 0 0

 

 

I am creating an app in ruby on rails for shopify stores and in that app I want to sync shopify products, I have done that for now using webhooks on product creation event.

But Is there any other way other than webhooks to sync shopify products to Ruby on Rails application? as I don't want my customers to do any manual setting for this.

 

 

Replies 4 (4)

Jayvin
Shopify Partner
284 42 89

Hi,

Just create a cron task that will go through all the products every hour and do the sync.

banned
ankitaagrawal-k
New Member
4 0 0

With cron, real time synching will not happen.

Just one more thing, can we create webhooks in shopify stores at the time of installation of app via api and thus merchants won't require to do that manually?

I tried creating webhooks using APIs only so that there will not be any manual work for merchants but I can't see webhooks got created in shopify stores.

I am using shopify oauth (https://github.com/Shopify/omniauth-shopify-oauth2) for authentication, not sure if I am doing anything wrong.

 

Below is my omniauth.rb file in intializers.

 

Rails.application.config.middleware.use OmniAuth::Builder do
   provider :shopify,
      Rails.application.credentials.dig(:shopify_oauth, :client_id),
      Rails.application.credentials.dig(:shopify_oauth, :client_secret),
      scope: 'read_products,write_products,read_orders,write_orders',
      embedded_app: true,
      webhooks: [
      {
         topic: 'products/update',
         address: 'https://mydomain/webhooks',
         format: 'json'
       }
     ],

     setup: ->(env) {
        request = Rack::Request.new(env)
        site = if request.params['shop']
            "https://#{request.params['shop']}"
        else
            ''
        end
        env['omniauth.strategy'].options[:client_options][:site] = site
     }
end

Jayvin
Shopify Partner
284 42 89

Yes, you can create webhooks when merchant install your app. Have a look at the references here

banned
ankitaagrawal-k
New Member
4 0 0

I tried creating webhooks using APIs at the time of installation but even after that I can not see any webhooks got created on shopify store.