00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 class Mage_CatalogIndex_Model_Mysql4_Indexer_Minimalprice extends Mage_CatalogIndex_Model_Mysql4_Indexer_Abstract
00034 {
00035 protected function _construct()
00036 {
00037 $this->_init('catalogindex/minimal_price', 'index_id');
00038
00039 $this->_entityIdFieldName = 'entity_id';
00040 $this->_storeIdFieldName = 'store_id';
00041 }
00042
00043 public function getMinimalValue($conditions)
00044 {
00045 $select = $this->_getReadAdapter()->select();
00046 $select->from($this->getTable('catalogindex/price'), 'MIN(value)');
00047 foreach ($conditions as $field=>$value) {
00048 $condition = "{$field} = ?";
00049 if (is_array($value))
00050 $condition = "{$field} in (?)";
00051
00052 $select->where($condition, $value);
00053 }
00054
00055 return $this->_getReadAdapter()->fetchOne($select);
00056 }
00057
00058 public function cleanup($productId, $storeId = null, $attributeId = null)
00059 {
00060 $conditions[] = $this->_getWriteAdapter()->quoteInto("{$this->_entityIdFieldName} = ?", $productId);
00061
00062 if (!is_null($storeId))
00063 $conditions[] = $this->_getWriteAdapter()->quoteInto("{$this->_storeIdFieldName} = ?", $storeId);
00064
00065 $conditions = implode (' AND ', $conditions);
00066 $this->_getWriteAdapter()->delete($this->getMainTable(), $conditions);
00067 }
00068 }