Mage_CatalogInventory_Model_Mysql4_Stock_Item Class Reference

Inheritance diagram for Mage_CatalogInventory_Model_Mysql4_Stock_Item:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 loadByProductId (Mage_CatalogInventory_Model_Stock_Item $item, $productId)
 addCatalogInventoryToProductCollection ($productCollection)

Protected Member Functions

 _construct ()
 _getLoadSelect ($field, $value, $object)


Detailed Description

Definition at line 34 of file Item.php.


Member Function Documentation

_construct (  )  [protected]

Resource initialization

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 36 of file Item.php.

00037     {
00038         $this->_init('cataloginventory/stock_item', 'item_id');
00039     }

_getLoadSelect ( field,
value,
object 
) [protected]

Retrieve select object and join it to product entity table to get type ids

Parameters:
string $field
mixed $value
object $object
Returns:
Zend_Db_Select

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 66 of file Item.php.

00067     {
00068         return parent::_getLoadSelect($field, $value, $object)
00069             ->joinInner(array('p' => $this->getTable('catalog/product')), 'product_id=p.entity_id', 'type_id')
00070         ;
00071     }

addCatalogInventoryToProductCollection ( productCollection  ) 

Add join for catalog in stock field to product collection

Parameters:
Mage_Catalog_Model_Entity_Product_Collection $productCollection
Returns:
Mage_CatalogInventory_Model_Mysql4_Stock_Item

Definition at line 79 of file Item.php.

00080     {
00081         $isStockManagedInConfig = (int) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
00082         $productCollection->joinTable('cataloginventory/stock_item',
00083             'product_id=entity_id',
00084             array(
00085                 'is_saleable' => new Zend_Db_Expr('(IF(IF(use_config_manage_stock, ' . $isStockManagedInConfig . ', manage_stock), is_in_stock, 1))'),
00086                 'inventory_in_stock' => 'is_in_stock'
00087             ),
00088             null, 'left');
00089         return $this;
00090     }

loadByProductId ( Mage_CatalogInventory_Model_Stock_Item item,
productId 
)

Loading stock item data by product

Parameters:
Mage_CatalogInventory_Model_Stock_Item $item
int $productId
Returns:
Mage_Core_Model_Mysql4_Abstract

Definition at line 48 of file Item.php.

00049     {
00050         $select = $this->_getLoadSelect('product_id', $productId, $item)
00051             ->where('stock_id=?', $item->getStockId());
00052 
00053         $item->setData($this->_getReadAdapter()->fetchRow($select));
00054         $this->_afterLoad($item);
00055         return $this;
00056     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:47 2009 for Magento by  doxygen 1.5.8