/**
  * After change Catalog Inventory Manage value process
  *
  * @return Mage_Adminhtml_Model_System_Config_Backend_Catalog_Inventory_Managestock
  */
 protected function _afterSave()
 {
     if ($this->getValue() != $this->getOldValue()) {
         $this->_stockStatusModel->rebuild();
     }
     return $this;
 }
Example #2
0
 /**
  * Save Product Status per website
  *
  * @param Mage_CatalogInventory_Model_Stock_Status $object
  * @param int $productId
  * @param int $status
  * @param float $qty
  * @param int $stockId
  * @param int|null $websiteId
  * @return Mage_CatalogInventory_Model_Mysql4_Stock_Status
  */
 public function saveProductStatus(Mage_CatalogInventory_Model_Stock_Status $object, $productId, $status, $qty = 0, $stockId = 1, $websiteId = null)
 {
     $websites = array_keys($object->getWebsites($websiteId));
     foreach ($websites as $websiteId) {
         $select = $this->_getWriteAdapter()->select()->from($this->getMainTable())->where('product_id=?', $productId)->where('website_id=?', $websiteId)->where('stock_id=?', $stockId);
         if ($row = $this->_getWriteAdapter()->fetchRow($select)) {
             $bind = array('qty' => $qty, 'stock_status' => $status);
             $where = array($this->_getWriteAdapter()->quoteInto('product_id=?', $row['product_id']), $this->_getWriteAdapter()->quoteInto('website_id=?', $row['website_id']), $this->_getWriteAdapter()->quoteInto('stock_id=?', $row['stock_id']));
             $this->_getWriteAdapter()->update($this->getMainTable(), $bind, $where);
         } else {
             $bind = array('product_id' => $productId, 'website_id' => $websiteId, 'stock_id' => $stockId, 'qty' => $qty, 'stock_status' => $status);
             $this->_getWriteAdapter()->insert($this->getMainTable(), $bind);
         }
     }
     return $this;
 }