1

How do I prevent product stock qty value showing negative values in admin? I have set Backorders to "No Backorders" but still it's showing negative values. can anybody please help me on this. Thanks

1

You can create a custom module and an event observer hook to the cataloginventory_stock_item_save_before event then you can validate if the qty will be saved as negative or perform some action.

Namespace/Module/etc/config.xml

<global>
...
    <events>
        <cataloginventory_stock_item_save_before>
            <observers>
                <namespace_module_stock_item_save_before>
                    <class>namespace_module/observer</class>
                    <method>stockItemSaveBefore</method>
                </namespace_module_stock_item_save_before>
            </observers>
        </cataloginventory_stock_item_save_before>
    </events>
</global>
...

Namespace/Module/Model/Observer.php

class Namespace_Module_Model_Observer
{
   public function stockItemSaveBefore(Varien_Event_Observer $observer)
   {
        $item = $observer->getEvent()->getItem();
        // Perform some action ...
   }
}

Now you can do with item qty as per your requirement.

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.