1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Catalog
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Catalog product tier price backend attribute model
30: *
31: * @category Mage
32: * @package Mage_Catalog
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Catalog_Model_Resource_Product_Attribute_Backend_Tierprice
36: extends Mage_Catalog_Model_Resource_Product_Attribute_Backend_Groupprice_Abstract
37: {
38: /**
39: * Initialize connection and define main table
40: *
41: */
42: protected function _construct()
43: {
44: $this->_init('catalog/product_attribute_tier_price', 'value_id');
45: }
46:
47: /**
48: * Add qty column
49: *
50: * @param array $columns
51: * @return array
52: */
53: protected function _loadPriceDataColumns($columns)
54: {
55: $columns = parent::_loadPriceDataColumns($columns);
56: $columns['price_qty'] = 'qty';
57: return $columns;
58: }
59:
60: /**
61: * Order by qty
62: *
63: * @param Varien_Db_Select $select
64: * @return Varien_Db_Select
65: */
66: protected function _loadPriceDataSelect($select)
67: {
68: $select->order('qty');
69: return $select;
70: }
71:
72: /**
73: * Load product tier prices
74: *
75: * @deprecated since 1.3.2.3
76: *
77: * @param Mage_Catalog_Model_Product $product
78: * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
79: * @return array
80: */
81: public function loadProductPrices($product, $attribute)
82: {
83: $websiteId = null;
84: if ($attribute->isScopeGlobal()) {
85: $websiteId = 0;
86: } else if ($product->getStoreId()) {
87: $websiteId = Mage::app()->getStore($product->getStoreId())->getWebsiteId();
88: }
89:
90: return $this->loadPriceData($product->getId(), $websiteId);
91: }
92:
93: /**
94: * Delete product tier price data from storage
95: *
96: * @deprecated since 1.3.2.3
97: *
98: * @param Mage_Catalog_Model_Product $product
99: * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
100: * @return Mage_Catalog_Model_Resource_Product_Attribute_Backend_Tierprice
101: */
102: public function deleteProductPrices($product, $attribute)
103: {
104: $websiteId = null;
105: if (!$attribute->isScopeGlobal()) {
106: $storeId = $product->getProductId();
107: if ($storeId) {
108: $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
109: }
110: }
111:
112: $this->deletePriceData($product->getId(), $websiteId);
113:
114: return $this;
115: }
116:
117: /**
118: * Insert product Tier Price to storage
119: *
120: * @deprecated since 1.3.2.3
121: *
122: * @param Mage_Catalog_Model_Product $product
123: * @param array $data
124: * @return Mage_Catalog_Model_Resource_Product_Attribute_Backend_Tierprice
125: */
126: public function insertProductPrice($product, $data)
127: {
128: $priceObject = new Varien_Object($data);
129: $priceObject->setEntityId($product->getId());
130:
131: return $this->savePriceData($priceObject);
132: }
133: }
134: