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 eav processor 00030 * 00031 * @author Magento Core Team <core@magentocommerce.com> 00032 */ 00033 class Mage_CatalogIndex_Model_Indexer_Eav extends Mage_CatalogIndex_Model_Indexer_Abstract 00034 { 00035 protected function _construct() 00036 { 00037 $this->_init('catalogindex/indexer_eav'); 00038 return parent::_construct(); 00039 } 00040 00041 public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null) 00042 { 00043 $data = array(); 00044 00045 $data['store_id'] = $attribute->getStoreId(); 00046 $data['entity_id'] = $object->getId(); 00047 $data['attribute_id'] = $attribute->getId(); 00048 $data['value'] = $object->getData($attribute->getAttributeCode()); 00049 00050 if ($attribute->getFrontendInput() == 'multiselect') { 00051 $origData = $data; 00052 $data = array(); 00053 00054 $value = explode(',', $origData['value']); 00055 foreach ($value as $item) { 00056 $row = $origData; 00057 $row['value'] = $item; 00058 $data[] = $row; 00059 } 00060 } 00061 00062 //return $this->_spreadDataForStores($object, $attribute, $data); 00063 return $data; 00064 } 00065 00066 protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) 00067 { 00068 if ($attribute->getIsFilterable() == 0 && $attribute->getIsVisibleInAdvancedSearch() == 0) { 00069 return false; 00070 } 00071 if ($attribute->getFrontendInput() != 'select' && $attribute->getFrontendInput() != 'multiselect') { 00072 return false; 00073 } 00074 00075 return true; 00076 } 00077 00078 protected function _getIndexableAttributeConditions() 00079 { 00080 $conditions = "frontend_input IN ('select', 'multiselect') AND (is_filterable IN (1, 2) OR is_visible_in_advanced_search = 1)"; 00081 return $conditions; 00082 00083 $conditions = array(); 00084 $conditions['frontend_input'] = array('select', 'multiselect'); 00085 $conditions['or']['is_filterable'] = array(1, 2); 00086 $conditions['or']['is_visible_in_advanced_search'] = 1; 00087 } 00088 }