1

If the customer is in a certain customer group category, what is the most efficient way to prevent stock decrease once the order is placed?

I want the quantity to remain unchanged only for some customers after they place an order.

1

You can add an observer for sales_order_save_after and try this:

Observer.php

public function salesOrderSaveAfter(Varien_Event_Observer $observer)
{
    $order   = $observer->getEvent()->getOrder();
    $groupId = $order->getQuote()->getCustomerGroupId();
    # adjust group ID
    if ($groupId == '1') {
        $items = $order->getItemsCollection();
        foreach ($items as $item) {
            $product   = $item->getProduct();
            $stockItem = $product->getStockItem();
            $stockItem->setQty($stockItem->getQty());
            $stockItem->save();
        }
    }
}
  • Very nice workaround. Will try to create observer.php in local directory and test it out. – Icon Jul 18 '17 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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