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 * Tier Price indexer 00030 * 00031 * @author Magento Core Team <core@magentocommerce.com> 00032 */ 00033 class Mage_CatalogIndex_Model_Indexer_Tierprice extends Mage_CatalogIndex_Model_Indexer_Abstract 00034 { 00035 protected $_processChildren = false; 00036 00037 protected function _construct() 00038 { 00039 $this->_init('catalogindex/indexer_price'); 00040 $this->_currencyModel = Mage::getModel('directory/currency'); 00041 $this->_customerGroups = Mage::getModel('customer/group')->getCollection(); 00042 00043 return parent::_construct(); 00044 } 00045 00046 public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null) 00047 { 00048 $data = array(); 00049 00050 $data['store_id'] = $attribute->getStoreId(); 00051 $data['entity_id'] = $object->getId(); 00052 $data['attribute_id'] = $attribute->getId(); 00053 00054 $result = array(); 00055 $values = $object->getData($attribute->getAttributeCode()); 00056 00057 if (!is_array($values)) { 00058 return $result; 00059 } 00060 00061 foreach ($values as $row) { 00062 if (isset($row['delete']) && $row['delete']) { 00063 continue; 00064 } 00065 00066 $data['qty'] = $row['price_qty']; 00067 $data['value'] = $row['price']; 00068 if ($row['cust_group'] == Mage_Customer_Model_Group::CUST_GROUP_ALL) { 00069 foreach ($this->_customerGroups as $group) { 00070 $data['customer_group_id'] = $group->getId(); 00071 $result[] = $data; 00072 } 00073 } else { 00074 $data['customer_group_id'] = $row['cust_group']; 00075 $result[] = $data; 00076 } 00077 00078 } 00079 00080 return $result; 00081 } 00082 00083 protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) 00084 { 00085 if ($attribute->getAttributeCode() != 'tier_price') { 00086 return false; 00087 } 00088 00089 return true; 00090 } 00091 00092 protected function _getIndexableAttributeConditions() 00093 { 00094 $conditions = array(); 00095 $conditions['attribute_code'] = 'tier_price'; 00096 00097 return $conditions; 00098 } 00099 }