5

I would like to prevent orders from being placed while an inventory update script runs.

We utilize a 3rd party warehouse management system (WMS) that has the final say in whether or not a part is in stock. Magento is configured to keep track of inventory (an order for 2 of SKU A will decrement SKU A's inventory by 2), but inevitably these systems become out of sync (due to defective or lost products, sales outside of Magento, etc). As such, we run an inventory sync every night where we request product counts from the WMS and update Magento with this data. The problem is that from the time we request the file until it finishes orders can still be placed in Magento and inventory can become out of sync. Since the update typically lasts ~15 mins, it was decided that Magento should just stop accepting orders during that time. Ideally, the site would still be navigable (is that a word?). I'd like to keep code changes to a minimum, but understand this probably cannot be achieved with configuration alone. A few of the avenues I've explored:

  1. Raise the minimum order amount to 9999999 and set an error message saying, "We are undergoing server maintenance, ordering is temporarily disabled"
  2. Touch maintenance.flag and remove when script completes

Alternatively, the inventory script can log the time it began and before updating inventory search for any orders from START_TIME until now to take into account anything the WMS did not know about. This seems like more work though and will certainly increase the processing time.

2 Answers 2

3

Touch maintenance.flag and remove when script completes

This is the preferred method because it not only follows best-practice with regard to Magento, but it requires no cache clearing to take effect, can be scripted into a deployment, and doesn't require Magento itself or a database connection to be fully running or functional to operate.

On the UX side people are quite used to seeing maintenance messages (thank your online banking for making this more popular) and more ecommerce outfits are becoming better at giving incentives on these maintenance pages to shoppers inconvenienced by the downtime. These incentives are usually coupon codes for a nominal amount to get them to come back after the maintenance window.

In my experience any 'backfill' operation (such as your WMS start_time interrogation method) is usually kludgey at best and recovery efforts are manual, prone to human error.

0

I'm not 100% sure whether you want to prevent people adding products to baskets, or just prevent them checking out. However, it sounds more like the latter so I'll go with that.

I would replace (rewrite) the checkout page with a content page explaining that checkout is unavailable. Disabling the whole site seems somewhat dramatic, although if the inventory sync reduces performance then that might indeed be preferable.

As @philwinkle suggests, you could also offer a discount coupon to encourage return and display a link back to the basket. For bonus points, you could even display the estimated time that the checkout will be available.

You could implement the checkout URL rewrite using a flag similar to the maintenance.flag solution that affects only the checkout URL, thus preventing a server restart when you start your inventory script.

This would require no changes as such to your Magento code base - just changes to your webserver configuration.

The feasibility of this options obviously depends on your hosting setup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.