Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Backend_Tierprice Class Reference

Inheritance diagram for Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Backend_Tierprice:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 loadProductPrices ($product, $attribute)
 deleteProductPrices ($product, $attribute)
 insertProductPrice ($product, $data)

Protected Member Functions

 _construct ()


Detailed Description

Definition at line 35 of file Tierprice.php.


Member Function Documentation

_construct (  )  [protected]

Resource initialization

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 38 of file Tierprice.php.

00039     {
00040         $this->_init('catalog/product_attribute_tier_price', 'value_id');
00041     }

deleteProductPrices ( product,
attribute 
)

Definition at line 70 of file Tierprice.php.

00071     {
00072         $condition = array();
00073 
00074         if (!$attribute->isScopeGlobal()) {
00075             if ($storeId = $product->getStoreId()) {
00076                 $condition[] = $this->_getWriteAdapter()->quoteInto('website_id IN (?)', array(0, Mage::app()->getStore($storeId)->getWebsiteId()));
00077             }
00078         }
00079 
00080         $condition[] = $this->_getWriteAdapter()->quoteInto('entity_id=?', $product->getId());
00081 
00082         $this->_getWriteAdapter()->delete($this->getMainTable(), implode(' AND ', $condition));
00083         return $this;
00084     }

insertProductPrice ( product,
data 
)

Definition at line 86 of file Tierprice.php.

00087     {
00088         $data['entity_id'] = $product->getId();
00089         $this->_getWriteAdapter()->insert($this->getMainTable(), $data);
00090         return $this;
00091     }

loadProductPrices ( product,
attribute 
)

Load product tier prices

Parameters:
Mage_Catalog_Model_Product $product
Mage_Catalog_Model_Resource_Eav_Attribute $attribute
Returns:
array

Definition at line 50 of file Tierprice.php.

00051     {
00052         $select = $this->_getReadAdapter()->select()
00053             ->from($this->getMainTable(), array(
00054                 'website_id', 'all_groups', 'cust_group' => 'customer_group_id',
00055                 'price_qty' => 'qty', 'price' => 'value'
00056             ))
00057             ->where('entity_id=?', $product->getId())
00058             ->order('qty');
00059         if ($attribute->isScopeGlobal()) {
00060             $select->where('website_id=?', 0);
00061         }
00062         else {
00063             if ($storeId = $product->getStoreId()) {
00064                 $select->where('website_id IN (?)', array(0, Mage::app()->getStore($storeId)->getWebsiteId()));
00065             }
00066         }
00067         return $this->_getReadAdapter()->fetchAll($select);
00068     }


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

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