Public Member Functions | |
loadByProductId (Mage_CatalogInventory_Model_Stock_Item $item, $productId) | |
addCatalogInventoryToProductCollection ($productCollection) | |
Protected Member Functions | |
_construct () | |
_getLoadSelect ($field, $value, $object) |
Definition at line 34 of file Item.php.
_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
string | $field | |
mixed | $value | |
object | $object |
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
Mage_Catalog_Model_Entity_Product_Collection | $productCollection |
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
Mage_CatalogInventory_Model_Stock_Item | $item | |
int | $productId |
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 }