Public Member Functions | |
getMinimalPrice ($products, $priceAttributes, $store) | |
Protected Member Functions | |
_prepareLinkFetchSelect ($store, $table, $idField, $whereField, $id, $additionalWheres=array()) |
Definition at line 35 of file Grouped.php.
_prepareLinkFetchSelect | ( | $ | store, | |
$ | table, | |||
$ | idField, | |||
$ | whereField, | |||
$ | id, | |||
$ | additionalWheres = array() | |||
) | [protected] |
Prepare select statement before 'fetchLinkInformation' function result fetch
int | $store | |
string | $table | |
string | $idField | |
string | $whereField | |
int | $id | |
array | $additionalWheres |
Reimplemented from Mage_CatalogIndex_Model_Mysql4_Data_Abstract.
Definition at line 124 of file Grouped.php.
00125 { 00126 $this->_addAttributeFilter($this->_getLinkSelect(), 'required_options', 'l', $idField, $store, 0); 00127 }
getMinimalPrice | ( | $ | products, | |
$ | priceAttributes, | |||
$ | store | |||
) |
Return minimal prices for specified products
array | $products | |
array | $priceAttributes | |
int | $store |
Reimplemented from Mage_CatalogIndex_Model_Mysql4_Data_Abstract.
Definition at line 45 of file Grouped.php.
00046 { 00047 $result = array(); 00048 $store = Mage::app()->getStore($store); 00049 00050 $select = $this->_getReadAdapter()->select() 00051 ->from($this->getTable('catalogindex/price'), array( 00052 'customer_group_id', 'value', 'tax_class_id')) 00053 ->where('entity_id IN(?)', $products) 00054 ->where('attribute_id IN(?)', $priceAttributes) 00055 ->where('website_id=?', $store->getWebsiteId()); 00056 $prices = $select->query()->fetchAll(); 00057 00058 $groups = Mage::getSingleton('catalogindex/retreiver')->getCustomerGroups(); 00059 foreach ($groups as $group) { 00060 $resultMinimal = null; 00061 $resultTaxClassId = 0; 00062 $taxClassId = 0; 00063 $customerGroup = $group->getId(); 00064 00065 $typedProducts = Mage::getSingleton('catalogindex/retreiver') 00066 ->assignProductTypes($products); 00067 foreach ($typedProducts as $type=>$typeIds) { 00068 $retreiver = Mage::getSingleton('catalogindex/retreiver')->getRetreiver($type); 00069 foreach ($typeIds as $id) { 00070 $finalPrice = $retreiver->getFinalPrice($id, $store, $group); 00071 if ((null === $resultMinimal) || ($finalPrice < $resultMinimal)) { 00072 $resultMinimal = $finalPrice; 00073 $resultTaxClassId = $retreiver->getTaxClassId($id, $store); 00074 } 00075 00076 $tiers = $retreiver->getTierPrices($id, $store); 00077 foreach ($tiers as $tier) { 00078 if ($tier['customer_group_id'] != $customerGroup && !$tier['all_groups']) { 00079 continue; 00080 } 00081 if ((null === $resultMinimal) || ($tier['value'] < $resultMinimal)) { 00082 $resultMinimal = $tier['value']; 00083 $resultTaxClassId = $retreiver->getTaxClassId($tier['entity_id'], $store); 00084 } 00085 } 00086 } 00087 } 00088 00089 foreach ($prices as $one) { 00090 if ($one['customer_group_id'] != $customerGroup) { 00091 continue; 00092 } 00093 00094 if ((null === $resultMinimal) || ($one['value'] < $resultMinimal)) { 00095 $resultMinimal = $one['value']; 00096 $taxClassId = $one['tax_class_id']; 00097 } else { 00098 $taxClassId = $resultTaxClassId; 00099 } 00100 } 00101 00102 if (!is_null($resultMinimal)){ 00103 $result[] = array( 00104 'customer_group_id' => $customerGroup, 00105 'minimal_value' => $resultMinimal, 00106 'tax_class_id' => $taxClassId 00107 ); 00108 } 00109 } 00110 00111 return $result; 00112 }