I am trying to understand what are the steps involved to developed extension in Magento CE to check (by sending SOAP message) for product availability on external inventory system during checkout process. Thanks ray

  • can you tell me what is mean by on external inventory system during checkout process
    – Amit Bera
    Commented Aug 28, 2014 at 6:12

1 Answer 1


To check an external stock system to verify that the amount is available you need to create an observer on the sales_quote_item_qty_set_after event. In your observer you can then check the remote system with the following example:

In config.xml add:


In your observer you can use:

 * Check if products qty is available before placing order
 * Throw Exception if not and quit order

public function salesQuoteItemQtySetAfter(Varien_Event_Observer $observer)
    $quoteItem = $observer->getEvent()->getItem();
    $qty = $quoteItem->getQty();

    $lastCheckResult = Mage::app()->loadCache('api_check_' . $quoteItem->getId() . '_' . $qty);
    if ($lastCheckResult == '') {
        $lastCheckResult = true;
        // Check remote SOAP API
        if (!$api->checkStockQty($quoteItem->getSku(), $qty)) {
            $lastCheckResult = false;

    // Cache API Response for 1 minute to minimize requests
    Mage::app()->saveCache($lastCheckResult, 'api_check_' . $quoteItem->getId() . '_' . $qty, array(), 60);

    // If the qty is not available then throw an exception to display an error and disable the Checkout button in the cart page.
    if (!$lastCheckResult) {
            Mage::helper('cataloginventory')->__('The requested Qty is not available.')
  • Thank you for the suggestion. What about built-in observer in Magento (cataloginventory/observer) on the same event sales_quote_item_qty_set_after? Do I have to turn this off?
    – raybi
    Commented Aug 29, 2014 at 5:03
  • Hi Vladimir. Would this work also if we know the external stock qty thru CSV stock updates? Or would you use a commercial extension? Thx
    – snh_nl
    Commented Jun 21, 2016 at 18:32
  • It should be possible to write your own wrapper for the CSV stockupdates to check the contents of that file. But maybe its easier to have it stored in a database as it makes checking easier. Commented Jun 21, 2016 at 19:46

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.