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: * Catalog indexer price processor
30: *
31: * @method Mage_CatalogIndex_Model_Resource_Indexer_Price _getResource()
32: * @method Mage_CatalogIndex_Model_Resource_Indexer_Price getResource()
33: * @method Mage_CatalogIndex_Model_Indexer_Price setEntityId(int $value)
34: * @method int getCustomerGroupId()
35: * @method Mage_CatalogIndex_Model_Indexer_Price setCustomerGroupId(int $value)
36: * @method int getWebsiteId()
37: * @method Mage_CatalogIndex_Model_Indexer_Price setWebsiteId(int $value)
38: * @method int getTaxClassId()
39: * @method Mage_CatalogIndex_Model_Indexer_Price setTaxClassId(int $value)
40: * @method float getPrice()
41: * @method Mage_CatalogIndex_Model_Indexer_Price setPrice(float $value)
42: * @method float getFinalPrice()
43: * @method Mage_CatalogIndex_Model_Indexer_Price setFinalPrice(float $value)
44: * @method float getMinPrice()
45: * @method Mage_CatalogIndex_Model_Indexer_Price setMinPrice(float $value)
46: * @method float getMaxPrice()
47: * @method Mage_CatalogIndex_Model_Indexer_Price setMaxPrice(float $value)
48: * @method float getTierPrice()
49: * @method Mage_CatalogIndex_Model_Indexer_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_Indexer_Price extends Mage_CatalogIndex_Model_Indexer_Abstract
56: {
57: protected $_customerGroups = array();
58: protected $_processChildrenForConfigurable = false;
59:
60: protected function _construct()
61: {
62: $this->_init('catalogindex/indexer_price');
63: $this->_customerGroups = Mage::getModel('customer/group')->getCollection();
64: }
65:
66: public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null)
67: {
68: $data = array();
69:
70: $data['store_id'] = $attribute->getStoreId();
71: $data['entity_id'] = $object->getId();
72: $data['attribute_id'] = $attribute->getId();
73: $data['value'] = $object->getData($attribute->getAttributeCode());
74:
75: if ($attribute->getAttributeCode() == 'price') {
76: $result = array();
77: foreach ($this->_customerGroups as $group) {
78: $object->setCustomerGroupId($group->getId());
79: $finalPrice = $object->getFinalPrice();
80: $row = $data;
81: $row['customer_group_id'] = $group->getId();
82: $row['value'] = $finalPrice;
83: $result[] = $row;
84: }
85: return $result;
86: }
87:
88: return $data;
89: }
90:
91: protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
92: {
93: if ($attribute->getFrontendInput() != 'price') {
94: return false;
95: }
96: if ($attribute->getAttributeCode() == 'tier_price') {
97: return false;
98: }
99: if ($attribute->getAttributeCode() == 'minimal_price') {
100: return false;
101: }
102:
103: return true;
104: }
105:
106: protected function _getIndexableAttributeConditions()
107: {
108: $conditions = "frontend_input = 'price' AND attribute_code <> 'price'";
109: return $conditions;
110: }
111: }
112: