1

Want to make a change in the code, so if the stock go to 0 then and the Manufacturer's Suggested Retail Price are higher then the sale price, then it will change to price to Manufacturer's Suggested Retail Price.

I use Magento ver. 1.9.3.3

Thanks

1 Answers1

0

app/code/core/Mage/CatalogInventory/Model/Observer.php

Check checkoutAllSubmitAfter method which is responsible for updating stock qty.

/**
 * Subtract qtys of quote item products after multishipping checkout
 *
 * @param Varien_Event_Observer $observer
 * @return Mage_CatalogInventory_Model_Observer
 */
public function checkoutAllSubmitAfter(Varien_Event_Observer $observer)
{
    $quote = $observer->getEvent()->getQuote();
    if (!$quote->getInventoryProcessed()) {
        $this->subtractQuoteInventory($observer);
        $this->reindexQuoteInventory($observer);
    }
    return $this;
}

Now check following class

app/code/core/Mage/CatalogInventory/Model/Stock.php

registerProductsSale is the main method:

/**
 * Subtract product qtys from stock.
 * Return array of items that require full save
 *
 * @param array $items
 * @return array
 */
public function registerProductsSale($items)
{
    $qtys = $this->_prepareProductQtys($items);
    $item = Mage::getModel('cataloginventory/stock_item');
    $this->_getResource()->beginTransaction();
    $stockInfo = $this->_getResource()->getProductsStock($this, array_keys($qtys), true);
    $fullSaveItems = array();
    foreach ($stockInfo as $itemInfo) {
        $item->setData($itemInfo);
        if (!$item->checkQty($qtys[$item->getProductId()])) {
            $this->_getResource()->commit();
            Mage::throwException(Mage::helper('cataloginventory')->__('Not all products are available in the requested quantity'));
        }
        $item->subtractQty($qtys[$item->getProductId()]);
        if (!$item->verifyStock() || $item->verifyNotification()) {
            $fullSaveItems[] = clone $item;
        }
    }
    $this->_getResource()->correctItemsQty($this, $qtys, '-');
    $this->_getResource()->commit();
    return $fullSaveItems;
}

Don't modify the core file. Overwrite this class and modify your logic.

Sohel Rana
  • 35,846
  • 3
  • 72
  • 90