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_Downloadable_Adminhtml_Downloadable_FileController
  • Mage_Downloadable_Adminhtml_Downloadable_Product_EditController
  • Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable
  • Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Links
  • Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Samples
  • Mage_Downloadable_Block_Adminhtml_Sales_Items_Column_Downloadable_Name
  • Mage_Downloadable_Block_Catalog_Product_Links
  • Mage_Downloadable_Block_Catalog_Product_Samples
  • Mage_Downloadable_Block_Catalog_Product_View_Type
  • Mage_Downloadable_Block_Checkout_Cart_Item_Renderer
  • Mage_Downloadable_Block_Checkout_Success
  • Mage_Downloadable_Block_Customer_Products_List
  • Mage_Downloadable_Block_Sales_Order_Email_Items_Downloadable
  • Mage_Downloadable_Block_Sales_Order_Email_Items_Order_Downloadable
  • Mage_Downloadable_Block_Sales_Order_Item_Renderer_Downloadable
  • Mage_Downloadable_CustomerController
  • Mage_Downloadable_DownloadController
  • Mage_Downloadable_Helper_Catalog_Product_Configuration
  • Mage_Downloadable_Helper_Data
  • Mage_Downloadable_Helper_Download
  • Mage_Downloadable_Helper_File
  • Mage_Downloadable_Model_CatalogIndex_Data_Downloadable
  • Mage_Downloadable_Model_Link
  • Mage_Downloadable_Model_Link_Api
  • Mage_Downloadable_Model_Link_Api_Uploader
  • Mage_Downloadable_Model_Link_Api_V2
  • Mage_Downloadable_Model_Link_Api_Validator
  • Mage_Downloadable_Model_Link_Purchased
  • Mage_Downloadable_Model_Link_Purchased_Item
  • Mage_Downloadable_Model_Mysql4_Indexer_Price
  • Mage_Downloadable_Model_Mysql4_Link
  • Mage_Downloadable_Model_Mysql4_Link_Collection
  • Mage_Downloadable_Model_Mysql4_Link_Purchased
  • Mage_Downloadable_Model_Mysql4_Link_Purchased_Collection
  • Mage_Downloadable_Model_Mysql4_Link_Purchased_Item
  • Mage_Downloadable_Model_Mysql4_Link_Purchased_Item_Collection
  • Mage_Downloadable_Model_Mysql4_Sample
  • Mage_Downloadable_Model_Mysql4_Sample_Collection
  • Mage_Downloadable_Model_Observer
  • Mage_Downloadable_Model_Product_Price
  • Mage_Downloadable_Model_Product_Type
  • Mage_Downloadable_Model_Resource_Indexer_Price
  • Mage_Downloadable_Model_Resource_Link
  • Mage_Downloadable_Model_Resource_Link_Collection
  • Mage_Downloadable_Model_Resource_Link_Purchased
  • Mage_Downloadable_Model_Resource_Link_Purchased_Collection
  • Mage_Downloadable_Model_Resource_Link_Purchased_Item
  • Mage_Downloadable_Model_Resource_Link_Purchased_Item_Collection
  • Mage_Downloadable_Model_Resource_Sample
  • Mage_Downloadable_Model_Resource_Sample_Collection
  • Mage_Downloadable_Model_Sales_Order_Pdf_Items_Abstract
  • Mage_Downloadable_Model_Sales_Order_Pdf_Items_Creditmemo
  • Mage_Downloadable_Model_Sales_Order_Pdf_Items_Invoice
  • Mage_Downloadable_Model_Sample
  • Mage_Downloadable_Model_System_Config_Source_Contentdisposition
  • Mage_Downloadable_Model_System_Config_Source_Orderitemstatus
  • 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_Downloadable
 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:  * Downloadable products Price indexer resource model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Downloadable
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Downloadable_Model_Resource_Indexer_Price extends Mage_Catalog_Model_Resource_Product_Indexer_Price_Default
 36: {
 37:     /**
 38:      * Reindex temporary (price result data) for all products
 39:      *
 40:      * @return Mage_Downloadable_Model_Resource_Indexer_Price
 41:      */
 42:     public function reindexAll()
 43:     {
 44:         $this->useIdxTable(true);
 45:         $this->beginTransaction();
 46:         try {
 47:             $this->_prepareFinalPriceData();
 48:             $this->_applyCustomOption();
 49:             $this->_applyDownloadableLink();
 50:             $this->_movePriceDataToIndexTable();
 51:             $this->commit();
 52:         } catch (Exception $e) {
 53:             $this->rollBack();
 54:             throw $e;
 55:         }
 56:         return $this;
 57:     }
 58: 
 59:     /**
 60:      * Reindex temporary (price result data) for defined product(s)
 61:      *
 62:      * @param int|array $entityIds
 63:      * @return Mage_Downloadable_Model_Resource_Indexer_Price
 64:      */
 65:     public function reindexEntity($entityIds)
 66:     {
 67:         $this->_prepareFinalPriceData($entityIds);
 68:         $this->_applyCustomOption();
 69:         $this->_applyDownloadableLink();
 70:         $this->_movePriceDataToIndexTable();
 71: 
 72:         return $this;
 73:     }
 74: 
 75:     /**
 76:      * Retrieve downloadable links price temporary index table name
 77:      *
 78:      * @see _prepareDefaultFinalPriceTable()
 79:      *
 80:      * @return string
 81:      */
 82:     protected function _getDownloadableLinkPriceTable()
 83:     {
 84:         if ($this->useIdxTable()) {
 85:             return $this->getTable('downloadable/product_price_indexer_idx');
 86:         }
 87:         return $this->getTable('downloadable/product_price_indexer_tmp');
 88:     }
 89: 
 90:     /**
 91:      * Prepare downloadable links price temporary index table
 92:      *
 93:      * @return Mage_Downloadable_Model_Resource_Indexer_Price
 94:      */
 95:     protected function _prepareDownloadableLinkPriceTable()
 96:     {
 97:         $this->_getWriteAdapter()->delete($this->_getDownloadableLinkPriceTable());
 98:         return $this;
 99:     }
100: 
101:     /**
102:      * Calculate and apply Downloadable links price to index
103:      *
104:      * @return Mage_Downloadable_Model_Resource_Indexer_Price
105:      */
106:     protected function _applyDownloadableLink()
107:     {
108:         $write  = $this->_getWriteAdapter();
109:         $table  = $this->_getDownloadableLinkPriceTable();
110: 
111:         $this->_prepareDownloadableLinkPriceTable();
112: 
113:         $dlType = $this->_getAttribute('links_purchased_separately');
114: 
115:         $ifPrice = $write->getIfNullSql('dlpw.price_id', 'dlpd.price');
116: 
117:         $select = $write->select()
118:             ->from(
119:                 array('i' => $this->_getDefaultFinalPriceTable()),
120:                 array('entity_id', 'customer_group_id', 'website_id'))
121:             ->join(
122:                 array('dl' => $dlType->getBackend()->getTable()),
123:                 "dl.entity_id = i.entity_id AND dl.attribute_id = {$dlType->getAttributeId()}"
124:                     . " AND dl.store_id = 0",
125:                 array())
126:             ->join(
127:                 array('dll' => $this->getTable('downloadable/link')),
128:                 'dll.product_id = i.entity_id',
129:                 array())
130:             ->join(
131:                 array('dlpd' => $this->getTable('downloadable/link_price')),
132:                 'dll.link_id = dlpd.link_id AND dlpd.website_id = 0',
133:                 array())
134:             ->joinLeft(
135:                 array('dlpw' => $this->getTable('downloadable/link_price')),
136:                 'dlpd.link_id = dlpw.link_id AND dlpw.website_id = i.website_id',
137:                 array())
138:             ->where('dl.value = ?', 1)
139:             ->group(array('i.entity_id', 'i.customer_group_id', 'i.website_id'))
140:             ->columns(array(
141:                 'min_price' => new Zend_Db_Expr('MIN('.$ifPrice.')'),
142:                 'max_price' => new Zend_Db_Expr('SUM('.$ifPrice.')')
143:             ));
144: 
145:         $query = $select->insertFromSelect($table);
146:         $write->query($query);
147: 
148:         $ifTierPrice = $write->getCheckSql('i.tier_price IS NOT NULL', '(i.tier_price + id.min_price)', 'NULL');
149:         $ifGroupPrice = $write->getCheckSql('i.group_price IS NOT NULL', '(i.group_price + id.min_price)', 'NULL');
150: 
151:         $select = $write->select()
152:             ->join(
153:                 array('id' => $table),
154:                 'i.entity_id = id.entity_id AND i.customer_group_id = id.customer_group_id'
155:                     .' AND i.website_id = id.website_id',
156:                 array())
157:             ->columns(array(
158:                 'min_price'   => new Zend_Db_Expr('i.min_price + id.min_price'),
159:                 'max_price'   => new Zend_Db_Expr('i.max_price + id.max_price'),
160:                 'tier_price'  => new Zend_Db_Expr($ifTierPrice),
161:                 'group_price' => new Zend_Db_Expr($ifGroupPrice),
162:             ));
163: 
164:         $query = $select->crossUpdateFromSelect(array('i' => $this->_getDefaultFinalPriceTable()));
165:         $write->query($query);
166: 
167:         $write->delete($table);
168: 
169:         return $this;
170:     }
171: }
172: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0