HOWTO Fix Autopilot Stuck in “Setting Up”
NOTE: You must have access to, and know how to use, the rails console in order to do this. For heroku, you can access this by typing
heroku run rails c -a incartupsell
at a terminal prompt
Example: store hommagenyc.myshopify.com
If the store is stuck in the “Setting Up” step, it means that they clicked the button to start automatically setting up the autopilot but something happened along the way to derail it. It can take up to ~20 minutes to do all of the setup steps, so normally they are taken care of in a delayed job. The code is in app/workers/shop_worker.rb, in the class EnableAutopilotJob.
Here’s how to run it manually:
Open up a rails console to the production app and find the shop:
s = Shop.find_by(myshopify_domain: "hommagenyc.myshopify.com")
Run the commands in that job one by one:
s.fetch_data_on_companions s.check_offerable_inventory s.auto_offer
In this case, the first method errors out with this error: “ ActiveRecord::RecordNotUnique DETAIL: Key (shopify_id)=(3517846356055) already exists.”
So I look for this product:
p = Product.find_by(shopify_id: 3517846356055)
And I see that there’s something wrong with the record. The product exists in our database but it has no title, no stock information, etc. So I delete that product:
p.destroy
Then I go back and re-run the three steps in the EnableAutopilotJob. This time it succeeds. Great!