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 Data Retreiver Abstract Model
 30:  *
 31:  * @category   Mage
 32:  * @package    Mage_CatalogIndex
 33:  * @author     Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_CatalogIndex_Model_Data_Abstract extends Mage_Core_Model_Abstract
 36: {
 37:     /**
 38:      * Product Type instance
 39:      *
 40:      * @var Mage_Catalog_Model_Product_Type_Abstract
 41:      */
 42:     protected $_typeInstance;
 43: 
 44:     /**
 45:      * Defines when product type has children
 46:      *
 47:      * @var boolean
 48:      */
 49:     protected $_haveChildren = array(
 50:                         Mage_CatalogIndex_Model_Retreiver::CHILDREN_FOR_TIERS=>true,
 51:                         Mage_CatalogIndex_Model_Retreiver::CHILDREN_FOR_PRICES=>true,
 52:                         Mage_CatalogIndex_Model_Retreiver::CHILDREN_FOR_ATTRIBUTES=>true,
 53:                         );
 54: 
 55:     /**
 56:      * Defines when product type has parents
 57:      *
 58:      * @var boolean
 59:      */
 60:     protected $_haveParents = true;
 61: 
 62:     const LINK_GET_CHILDREN = 1;
 63:     const LINK_GET_PARENTS = 1;
 64: 
 65:     /**
 66:      * Initialize abstract resource model
 67:      *
 68:      */
 69:     protected function _construct()
 70:     {
 71:         $this->_init('catalogindex/data_abstract');
 72:     }
 73: 
 74:     /**
 75:      * Return all children ids
 76:      *
 77:      * @param Mage_Core_Model_Store $store
 78:      * @param int $parentId
 79:      * @return mixed
 80:      */
 81:     public function getChildProductIds($store, $parentIds)
 82:     {
 83:         if (!$this->_haveChildren) {
 84:             return false;
 85:         }
 86: 
 87:         if (!$this->_getLinkSettings()) {
 88:             return false;
 89:         }
 90: 
 91:         return $this->fetchLinkInformation($store, $this->_getLinkSettings(), self::LINK_GET_CHILDREN, $parentIds);
 92:     }
 93: 
 94:     /**
 95:      * Return all parent ids
 96:      *
 97:      * @param Mage_Core_Model_Store $store
 98:      * @param int $childId
 99:      * @return mixed
100:      */
101:     public function getParentProductIds($store, $childIds)
102:     {
103:         if (!$this->_haveParents) {
104:             return false;
105:         }
106: 
107:         if (!$this->_getLinkSettings()) {
108:             return false;
109:         }
110: 
111:         return $this->fetchLinkInformation($store, $this->_getLinkSettings(), self::LINK_GET_PARENTS, $childIds);
112:     }
113: 
114:     /**
115:      * Returns an array of product children/parents
116:      *
117:      * @param Mage_Core_Model_Store $store
118:      * @param array $settings
119:      * @param int $type
120:      * @param int $suppliedId
121:      */
122:     protected function fetchLinkInformation($store, $settings, $type, $suppliedId)
123:     {
124:         switch ($type) {
125:             case self::LINK_GET_CHILDREN:
126:                 $whereField = $settings['parent_field'];
127:                 $idField = $settings['child_field'];
128:                 break;
129: 
130:             case self::LINK_GET_PARENTS:
131:                 $idField = $settings['parent_field'];
132:                 $whereField = $settings['child_field'];
133:                 break;
134:         }
135: 
136:         $additional = array();
137:         if (isset($settings['additional']) && is_array($settings['additional'])) {
138:             $additional = $settings['additional'];
139:         }
140: 
141:         return $this->getResource()->fetchLinkInformation($store->getId(), $settings['table'], $idField, $whereField, $suppliedId, $additional);
142:     }
143: 
144:     /**
145:      * Fetch final price for product
146:      *
147:      * @param int $product
148:      * @param Mage_Core_Model_Store $store
149:      * @param Mage_Customer_Model_Group $group
150:      * @return float
151:      */
152:     public function getFinalPrice($product, $store, $group)
153:     {
154:         $basePrice = $specialPrice = $specialPriceFrom = $specialPriceTo = null;
155:         $priceId = Mage::getSingleton('eav/entity_attribute')->getIdByCode(Mage_Catalog_Model_Product::ENTITY, 'price');
156:         $specialPriceId = Mage::getSingleton('eav/entity_attribute')->getIdByCode(Mage_Catalog_Model_Product::ENTITY, 'special_price');
157:         $specialPriceFromId = Mage::getSingleton('eav/entity_attribute')->getIdByCode(Mage_Catalog_Model_Product::ENTITY, 'special_from_date');
158:         $specialPriceToId = Mage::getSingleton('eav/entity_attribute')->getIdByCode(Mage_Catalog_Model_Product::ENTITY, 'special_to_date');
159: 
160:         $attributes = array($priceId, $specialPriceId, $specialPriceFromId, $specialPriceToId);
161: 
162:         $productData = $this->getAttributeData($product, $attributes, $store);
163:         foreach ($productData as $row) {
164:             switch ($row['attribute_id']) {
165:                 case $priceId:
166:                     $basePrice = $row['value'];
167:                 break;
168:                 case $specialPriceId:
169:                     $specialPrice = $row['value'];
170:                 break;
171:                 case $specialPriceFromId:
172:                     $specialPriceFrom = $row['value'];
173:                 break;
174:                 case $specialPriceToId:
175:                     $specialPriceTo = $row['value'];
176:                 break;
177:             }
178:         }
179: 
180:         $finalPrice = Mage::getSingleton('catalog/product_type')
181:             ->priceFactory($this->getTypeCode())
182:             ->calculatePrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo, false, $store, $group, $product);
183: 
184:         return $finalPrice;
185:     }
186: 
187:     /**
188:      * Return minimal prices for specified products
189:      *
190:      * @param array $products
191:      * @param Mage_Core_Model_Store $store
192:      * @return array
193:      */
194:     public function getMinimalPrice($products, $store)
195:     {
196:         $priceAttributes = array(
197:             Mage::getSingleton('eav/entity_attribute')->getIdByCode(Mage_Catalog_Model_Product::ENTITY, 'tier_price'),
198:             Mage::getSingleton('eav/entity_attribute')->getIdByCode(Mage_Catalog_Model_Product::ENTITY, 'price'));
199: 
200:         $data = $this->getResource()->getMinimalPrice($products, $priceAttributes, $store->getId());
201: 
202:         $this->setMinimalPriceData($data);
203:         $eventData = array('indexer'=>$this, 'product_ids'=>$products, 'store'=>$store);
204:         Mage::dispatchEvent('catalogindex_get_minimal_price', $eventData);
205:         $data = $this->getMinimalPriceData();
206: 
207:         return $data;
208:     }
209: 
210:     /**
211:      * Get tax class id for a product
212:      *
213:      * @param int $productId
214:      * @param Mage_Core_Model_Store $store
215:      * @return int
216:      */
217:     public function getTaxClassId($productId, $store)
218:     {
219:         $attributeId = Mage::getSingleton('eav/entity_attribute')->getIdByCode(Mage_Catalog_Model_Product::ENTITY, 'tax_class_id');
220:         $taxClassId  = $this->getResource()->getAttributeData(array($productId), array($attributeId), $store->getId());
221:         if (is_array($taxClassId) && isset($taxClassId[0]['value'])) {
222:             $taxClassId = $taxClassId[0]['value'];
223:         }
224:         else {
225:             $taxClassId = 0;
226:         }
227:         return $taxClassId;
228:     }
229: 
230:     /**
231:      * Return tier data for specified products in specified store
232:      *
233:      * @param array $products
234:      * @param Mage_Core_Model_Store $store
235:      * @return mixed
236:      */
237:     public function getTierPrices($products, $store)
238:     {
239:         return $this->getResource()->getTierPrices($products, $store->getWebsiteId());
240:     }
241: 
242:     /**
243:      * Retreive specified attribute data for specified products from specified store
244:      *
245:      * @param array $products
246:      * @param array $attributes
247:      * @param Mage_Core_Model_Store $store
248:      */
249:     public function getAttributeData($products, $attributes, $store)
250:     {
251:         return $this->getResource()->getAttributeData($products, $attributes, $store->getId());
252:     }
253: 
254:     /**
255:      * Retreive product type code
256:      *
257:      * @return string
258:      */
259:     public function getTypeCode()
260:     {
261:         Mage::throwException('Define custom data retreiver with getTypeCode function');
262:     }
263: 
264:     /**
265:      * Get child link table and field settings
266:      *
267:      * @return mixed
268:      */
269:     protected function _getLinkSettings()
270:     {
271:         return false;
272:     }
273: 
274:     /**
275:      * Returns if type supports children of the specified type
276:      *
277:      * @param int $type
278:      * @return bool
279:      */
280:     public function areChildrenIndexable($type)
281:     {
282:         if (!$this->_haveChildren || !isset($this->_haveChildren[$type]) || !$this->_haveChildren[$type]) {
283:             return false;
284:         }
285:         return true;
286:     }
287: 
288:     /**
289:      * Retrieve Product Type Instance
290:      *
291:      * @return Mage_Catalog_Model_Product_Type_Abstract
292:      */
293:     public function getTypeInstance()
294:     {
295:         if (is_null($this->_typeInstance)) {
296:             $product = new Varien_Object();
297:             $product->setTypeId($this->getTypeCode());
298:             $this->_typeInstance = Mage::getSingleton('catalog/product_type')
299:                 ->factory($product, true);
300:         }
301:         return $this->_typeInstance;
302:     }
303: }
304: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0