Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_CatalogIndex_Model_Aggregation
  • Mage_CatalogIndex_Model_Attribute
  • Mage_CatalogIndex_Model_Catalog_Index_Flag
  • Mage_CatalogIndex_Model_Catalog_Index_Kill_Flag
  • Mage_CatalogIndex_Model_Data_Abstract
  • Mage_CatalogIndex_Model_Data_Configurable
  • Mage_CatalogIndex_Model_Data_Grouped
  • Mage_CatalogIndex_Model_Data_Simple
  • Mage_CatalogIndex_Model_Data_Virtual
  • Mage_CatalogIndex_Model_Indexer
  • Mage_CatalogIndex_Model_Indexer_Abstract
  • Mage_CatalogIndex_Model_Indexer_Eav
  • Mage_CatalogIndex_Model_Indexer_Minimalprice
  • Mage_CatalogIndex_Model_Indexer_Price
  • Mage_CatalogIndex_Model_Indexer_Tierprice
  • Mage_CatalogIndex_Model_Mysql4_Abstract
  • Mage_CatalogIndex_Model_Mysql4_Aggregation
  • Mage_CatalogIndex_Model_Mysql4_Attribute
  • Mage_CatalogIndex_Model_Mysql4_Data_Abstract
  • Mage_CatalogIndex_Model_Mysql4_Data_Configurable
  • Mage_CatalogIndex_Model_Mysql4_Data_Grouped
  • Mage_CatalogIndex_Model_Mysql4_Indexer
  • Mage_CatalogIndex_Model_Mysql4_Indexer_Abstract
  • Mage_CatalogIndex_Model_Mysql4_Indexer_Eav
  • Mage_CatalogIndex_Model_Mysql4_Indexer_Minimalprice
  • Mage_CatalogIndex_Model_Mysql4_Indexer_Price
  • Mage_CatalogIndex_Model_Mysql4_Price
  • Mage_CatalogIndex_Model_Mysql4_Retreiver
  • Mage_CatalogIndex_Model_Mysql4_Setup
  • Mage_CatalogIndex_Model_Observer
  • Mage_CatalogIndex_Model_Price
  • Mage_CatalogIndex_Model_Resource_Abstract
  • Mage_CatalogIndex_Model_Resource_Aggregation
  • Mage_CatalogIndex_Model_Resource_Attribute
  • Mage_CatalogIndex_Model_Resource_Data_Abstract
  • Mage_CatalogIndex_Model_Resource_Data_Configurable
  • Mage_CatalogIndex_Model_Resource_Data_Grouped
  • Mage_CatalogIndex_Model_Resource_Indexer
  • Mage_CatalogIndex_Model_Resource_Indexer_Abstract
  • Mage_CatalogIndex_Model_Resource_Indexer_Eav
  • Mage_CatalogIndex_Model_Resource_Indexer_Minimalprice
  • Mage_CatalogIndex_Model_Resource_Indexer_Price
  • Mage_CatalogIndex_Model_Resource_Price
  • Mage_CatalogIndex_Model_Resource_Retreiver
  • Mage_CatalogIndex_Model_Resource_Setup
  • Mage_CatalogIndex_Model_Retreiver

Interfaces

  • Mage_CatalogIndex_Model_Indexer_Interface
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_CatalogIndex
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * CatalogIndex Grouped Products Data Retriever Resource Model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_CatalogIndex
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_CatalogIndex_Model_Resource_Data_Grouped extends Mage_CatalogIndex_Model_Resource_Data_Abstract
 36: {
 37:     /**
 38:      * Return minimal prices for specified products
 39:      *
 40:      * @param array $products
 41:      * @param array $priceAttributes
 42:      * @param int $store
 43:      * @return array
 44:      */
 45:     public function getMinimalPrice($products, $priceAttributes, $store)
 46:     {
 47:         $result = array();
 48:         $store  = Mage::app()->getStore($store);
 49: 
 50:         $select = $this->_getReadAdapter()->select()
 51:             ->from($this->getTable('catalogindex/price'), array(
 52:                 'customer_group_id', 'value', 'tax_class_id'))
 53:             ->where('entity_id IN(?)', $products)
 54:             ->where('attribute_id IN(?)', $priceAttributes)
 55:             ->where('website_id=?', $store->getWebsiteId());
 56:         $prices = $select->query()->fetchAll();
 57: 
 58:         $groups = Mage::getSingleton('catalogindex/retreiver')->getCustomerGroups();
 59:         foreach ($groups as $group) {
 60:             $resultMinimal      = null;
 61:             $resultTaxClassId   = 0;
 62:             $taxClassId         = 0;
 63:             $customerGroup      = $group->getId();
 64: 
 65:             $typedProducts = Mage::getSingleton('catalogindex/retreiver')
 66:                 ->assignProductTypes($products);
 67:             foreach ($typedProducts as $type=>$typeIds) {
 68:                 $retreiver = Mage::getSingleton('catalogindex/retreiver')->getRetreiver($type);
 69:                 foreach ($typeIds as $id) {
 70:                     $finalPrice = $retreiver->getFinalPrice($id, $store, $group);
 71:                     if ((null === $resultMinimal) || ($finalPrice < $resultMinimal)) {
 72:                         $resultMinimal    = $finalPrice;
 73:                         $resultTaxClassId = $retreiver->getTaxClassId($id, $store);
 74:                     }
 75: 
 76:                     $tiers = $retreiver->getTierPrices($id, $store);
 77:                     foreach ($tiers as $tier) {
 78:                         if ($tier['customer_group_id'] != $customerGroup && !$tier['all_groups']) {
 79:                             continue;
 80:                         }
 81:                         if ((null === $resultMinimal) || ($tier['value'] < $resultMinimal)) {
 82:                             $resultMinimal    = $tier['value'];
 83:                             $resultTaxClassId = $retreiver->getTaxClassId($tier['entity_id'], $store);
 84:                         }
 85:                     }
 86:                 }
 87:             }
 88: 
 89:             foreach ($prices as $one) {
 90:                 if ($one['customer_group_id'] != $customerGroup) {
 91:                     continue;
 92:                 }
 93: 
 94:                 if ((null === $resultMinimal) || ($one['value'] < $resultMinimal)) {
 95:                     $resultMinimal = $one['value'];
 96:                     $taxClassId    = $one['tax_class_id'];
 97:                 } else {
 98:                     $taxClassId = $resultTaxClassId;
 99:                 }
100:             }
101: 
102:             if (!is_null($resultMinimal)){
103:                 $result[] = array(
104:                     'customer_group_id' => $customerGroup,
105:                     'minimal_value'     => $resultMinimal,
106:                     'tax_class_id'      => $taxClassId
107:                 );
108:             }
109:         }
110: 
111:         return $result;
112:     }
113: 
114:     /**
115:      * Prepare select statement before 'fetchLinkInformation' function result fetch
116:      *
117:      * @param int $store
118:      * @param string $table
119:      * @param string $idField
120:      * @param string $whereField
121:      * @param int $id
122:      * @param array $additionalWheres
123:      */
124:     protected function _prepareLinkFetchSelect($store, $table, $idField, $whereField, $id, $additionalWheres = array())
125:     {
126:         $this->_addAttributeFilter($this->_getLinkSelect(), 'required_options', 'l', $idField, $store, 0);
127:     }
128: }
129: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0