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_CatalogIndex
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: * Price index model
30: *
31: * @method Mage_CatalogIndex_Model_Resource_Price _getResource()
32: * @method Mage_CatalogIndex_Model_Resource_Price getResource()
33: * @method Mage_CatalogIndex_Model_Price setEntityId(int $value)
34: * @method int getCustomerGroupId()
35: * @method Mage_CatalogIndex_Model_Price setCustomerGroupId(int $value)
36: * @method int getWebsiteId()
37: * @method Mage_CatalogIndex_Model_Price setWebsiteId(int $value)
38: * @method int getTaxClassId()
39: * @method Mage_CatalogIndex_Model_Price setTaxClassId(int $value)
40: * @method float getPrice()
41: * @method Mage_CatalogIndex_Model_Price setPrice(float $value)
42: * @method float getFinalPrice()
43: * @method Mage_CatalogIndex_Model_Price setFinalPrice(float $value)
44: * @method float getMinPrice()
45: * @method Mage_CatalogIndex_Model_Price setMinPrice(float $value)
46: * @method float getMaxPrice()
47: * @method Mage_CatalogIndex_Model_Price setMaxPrice(float $value)
48: * @method float getTierPrice()
49: * @method Mage_CatalogIndex_Model_Price setTierPrice(float $value)
50: *
51: * @category Mage
52: * @package Mage_CatalogIndex
53: * @author Magento Core Team <core@magentocommerce.com>
54: */
55: class Mage_CatalogIndex_Model_Price extends Mage_Core_Model_Abstract
56: {
57: protected function _construct()
58: {
59: $this->_init('catalogindex/price');
60: $this->_getResource()->setStoreId(Mage::app()->getStore()->getId());
61: $this->_getResource()->setRate(Mage::app()->getStore()->getCurrentCurrencyRate());
62: $this->_getResource()->setCustomerGroupId(Mage::getSingleton('customer/session')->getCustomerGroupId());
63: }
64:
65: public function getMaxValue($attribute, $entityIdsFilter)
66: {
67: return $this->_getResource()->getMaxValue($attribute, $entityIdsFilter);
68: }
69:
70: public function getCount($attribute, $range, $entitySelect)
71: {
72: return $this->_getResource()->getCount($range, $attribute, $entitySelect);
73: }
74:
75: public function getFilteredEntities($attribute, $range, $index, $entityIdsFilter)
76: {
77: return $this->_getResource()->getFilteredEntities($range, $index, $attribute, $entityIdsFilter);
78: }
79:
80: public function applyFilterToCollection($collection, $attribute, $range, $index)
81: {
82: return $this->_getResource()->applyFilterToCollection($collection, $attribute, $range, $index);
83: }
84:
85: public function addMinimalPrices(Mage_Catalog_Model_Resource_Product_Collection $collection)
86: {
87: $minimalPrices = $this->_getResource()->getMinimalPrices($collection->getLoadedIds());
88:
89: foreach ($minimalPrices as $row) {
90: $item = $collection->getItemById($row['entity_id']);
91: if ($item) {
92: $item->setData('minimal_price', $row['value']);
93: $item->setData('minimal_tax_class_id', $row['tax_class_id']);
94: }
95: }
96: }
97: }
98: