Public Member Functions | |
getId () | |
addItemsToProducts ($productCollection) | |
getItemCollection () | |
registerItemSale (Varien_Object $item) | |
backItemQty ($productId, $qty) | |
lockProductItems ($productIds) | |
addInStockFilterToCollection ($collection) | |
Public Attributes | |
const | BACKORDERS_NO = 0 |
const | BACKORDERS_YES_NONOTIFY = 1 |
const | BACKORDERS_YES_NOTIFY = 2 |
const | BACKORDERS_BELOW = 1 |
const | BACKORDERS_YES = 2 |
const | STOCK_OUT_OF_STOCK = 0 |
const | STOCK_IN_STOCK = 1 |
const | DEFAULT_STOCK_ID = 1 |
Protected Member Functions | |
_construct () |
Definition at line 32 of file Stock.php.
_construct | ( | ) | [protected] |
Enter description here...
Reimplemented from Varien_Object.
Definition at line 47 of file Stock.php.
00048 { 00049 $this->_init('cataloginventory/stock'); 00050 }
addInStockFilterToCollection | ( | $ | collection | ) |
Enter description here...
Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Link_Product_Collection | $collection |
Definition at line 162 of file Stock.php.
00163 { 00164 $this->getResource()->setInStockFilterToCollection($collection); 00165 return $this; 00166 }
addItemsToProducts | ( | $ | productCollection | ) |
Add stock item objects to products
collection | $products |
Definition at line 68 of file Stock.php.
00069 { 00070 $items = $this->getItemCollection() 00071 ->addProductsFilter($productCollection) 00072 ->joinStockStatus($productCollection->getStoreId()) 00073 ->load(); 00074 foreach ($items as $item) { 00075 foreach($productCollection as $product){ 00076 if($product->getId()==$item->getProductId()){ 00077 if($product instanceof Mage_Catalog_Model_Product) { 00078 $item->assignProduct($product); 00079 } 00080 } 00081 } 00082 } 00083 return $this; 00084 }
backItemQty | ( | $ | productId, | |
$ | qty | |||
) |
Get back to stock (when order is canceled or whatever else)
int | $productId | |
numeric | $qty |
Definition at line 130 of file Stock.php.
00131 { 00132 $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId); 00133 if ($stockItem->getId() && Mage::helper('catalogInventory')->isQty($stockItem->getTypeId())) { 00134 $stockItem->addQty($qty); 00135 if ($stockItem->getCanBackInStock() && $stockItem->getQty() > $stockItem->getMinQty()) { 00136 $stockItem->setIsInStock(true) 00137 ->setStockStatusChangedAutomaticallyFlag(true); 00138 } 00139 $stockItem->save(); 00140 } 00141 return $this; 00142 }
getId | ( | ) |
Retrieve stock identifier
Reimplemented from Mage_Core_Model_Abstract.
Definition at line 57 of file Stock.php.
getItemCollection | ( | ) |
Retrieve items collection object with stock filter
Definition at line 91 of file Stock.php.
00092 { 00093 return Mage::getResourceModel('cataloginventory/stock_item_collection') 00094 ->addStockFilter($this->getId()); 00095 }
lockProductItems | ( | $ | productIds | ) |
Lock stock items for product ids array
array | $productIds |
Definition at line 150 of file Stock.php.
00151 { 00152 $this->_getResource()->lockProductItems($this, $productIds); 00153 return $this; 00154 }
registerItemSale | ( | Varien_Object $ | item | ) |
Subtract ordered qty for product
Varien_Object | $item |
Definition at line 103 of file Stock.php.
00104 { 00105 if ($productId = $item->getProductId()) { 00106 $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId); 00107 if (Mage::helper('catalogInventory')->isQty($stockItem->getTypeId())) { 00108 if ($item->getStoreId()) { 00109 $stockItem->setStoreId($item->getStoreId()); 00110 } 00111 if ($stockItem->checkQty($item->getQtyOrdered()) || Mage::app()->getStore()->isAdmin()) { 00112 $stockItem->subtractQty($item->getQtyOrdered()); 00113 $stockItem->save(); 00114 } 00115 } 00116 } 00117 else { 00118 Mage::throwException(Mage::helper('cataloginventory')->__('Can not specify product identifier for order item')); 00119 } 00120 return $this; 00121 }
const BACKORDERS_BELOW = 1 |
const BACKORDERS_NO = 0 |
const BACKORDERS_YES = 2 |
const BACKORDERS_YES_NONOTIFY = 1 |
const BACKORDERS_YES_NOTIFY = 2 |
const DEFAULT_STOCK_ID = 1 |
const STOCK_IN_STOCK = 1 |
const STOCK_OUT_OF_STOCK = 0 |