00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_CatalogIndex 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 00028 /** 00029 * Catalog indexer price processor 00030 * 00031 * @author Magento Core Team <core@magentocommerce.com> 00032 */ 00033 class Mage_CatalogIndex_Model_Indexer_Price extends Mage_CatalogIndex_Model_Indexer_Abstract 00034 { 00035 protected $_customerGroups = array(); 00036 protected $_processChildrenForConfigurable = false; 00037 00038 protected function _construct() 00039 { 00040 $this->_init('catalogindex/indexer_price'); 00041 $this->_customerGroups = Mage::getModel('customer/group')->getCollection(); 00042 } 00043 00044 public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null) 00045 { 00046 $data = array(); 00047 00048 $data['store_id'] = $attribute->getStoreId(); 00049 $data['entity_id'] = $object->getId(); 00050 $data['attribute_id'] = $attribute->getId(); 00051 $data['value'] = $object->getData($attribute->getAttributeCode()); 00052 00053 if ($attribute->getAttributeCode() == 'price') { 00054 $result = array(); 00055 foreach ($this->_customerGroups as $group) { 00056 $object->setCustomerGroupId($group->getId()); 00057 $finalPrice = $object->getFinalPrice(); 00058 $row = $data; 00059 $row['customer_group_id'] = $group->getId(); 00060 $row['value'] = $finalPrice; 00061 $result[] = $row; 00062 } 00063 return $result; 00064 } 00065 00066 return $data; 00067 } 00068 00069 protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) 00070 { 00071 if ($attribute->getFrontendInput() != 'price') { 00072 return false; 00073 } 00074 if ($attribute->getAttributeCode() == 'tier_price') { 00075 return false; 00076 } 00077 if ($attribute->getAttributeCode() == 'minimal_price') { 00078 return false; 00079 } 00080 00081 return true; 00082 } 00083 00084 protected function _getIndexableAttributeConditions() 00085 { 00086 $conditions = "frontend_input = 'price' AND attribute_code <> 'price'"; 00087 return $conditions; 00088 } 00089 }