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_Bundle_Adminhtml_Bundle_Product_EditController
  • Mage_Bundle_Adminhtml_Bundle_SelectionController
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Composite_Fieldset_Options_Type_Checkbox
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Composite_Fieldset_Options_Type_Multi
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Composite_Fieldset_Options_Type_Radio
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Composite_Fieldset_Options_Type_Select
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes_Extend
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes_Special
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option_Search
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option_Search_Grid
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option_Selection
  • Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tabs
  • Mage_Bundle_Block_Adminhtml_Sales_Order_Items_Renderer
  • Mage_Bundle_Block_Adminhtml_Sales_Order_View_Items_Renderer
  • Mage_Bundle_Block_Catalog_Product_List_Partof
  • Mage_Bundle_Block_Catalog_Product_Price
  • Mage_Bundle_Block_Catalog_Product_View
  • Mage_Bundle_Block_Catalog_Product_View_Type_Bundle
  • Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option
  • Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox
  • Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Multi
  • Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio
  • Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Select
  • Mage_Bundle_Block_Checkout_Cart_Item_Renderer
  • Mage_Bundle_Block_Sales_Order_Items_Renderer
  • Mage_Bundle_Helper_Catalog_Product_Configuration
  • Mage_Bundle_Helper_Data
  • Mage_Bundle_Model_CatalogIndex_Data_Bundle
  • Mage_Bundle_Model_Mysql4_Bundle
  • Mage_Bundle_Model_Mysql4_Indexer_Price
  • Mage_Bundle_Model_Mysql4_Indexer_Stock
  • Mage_Bundle_Model_Mysql4_Option
  • Mage_Bundle_Model_Mysql4_Option_Collection
  • Mage_Bundle_Model_Mysql4_Price_Index
  • Mage_Bundle_Model_Mysql4_Selection
  • Mage_Bundle_Model_Mysql4_Selection_Collection
  • Mage_Bundle_Model_Observer
  • Mage_Bundle_Model_Option
  • Mage_Bundle_Model_Price_Index
  • Mage_Bundle_Model_Product_Attribute_Source_Price_View
  • Mage_Bundle_Model_Product_Price
  • Mage_Bundle_Model_Product_Type
  • Mage_Bundle_Model_Resource_Bundle
  • Mage_Bundle_Model_Resource_Indexer_Price
  • Mage_Bundle_Model_Resource_Indexer_Stock
  • Mage_Bundle_Model_Resource_Option
  • Mage_Bundle_Model_Resource_Option_Collection
  • Mage_Bundle_Model_Resource_Price_Index
  • Mage_Bundle_Model_Resource_Selection
  • Mage_Bundle_Model_Resource_Selection_Collection
  • Mage_Bundle_Model_Sales_Order_Pdf_Items_Abstract
  • Mage_Bundle_Model_Sales_Order_Pdf_Items_Shipment
  • Mage_Bundle_Model_Selection
  • Mage_Bundle_Model_Source_Option_Selection_Price_Type
  • Mage_Bundle_Model_Source_Option_Type
  • 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_Bundle
 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:  * Bundle Stock Status Indexer Resource Model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Bundle
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Bundle_Model_Resource_Indexer_Stock extends Mage_CatalogInventory_Model_Resource_Indexer_Stock_Default
 36: {
 37:     /**
 38:      * Reindex temporary (price result data) for defined product(s)
 39:      *
 40:      * @param int|array $entityIds
 41:      * @return Mage_Bundle_Model_Resource_Indexer_Stock
 42:      */
 43:     public function reindexEntity($entityIds)
 44:     {
 45:         $this->_updateIndex($entityIds);
 46: 
 47:         return $this;
 48:     }
 49: 
 50:     /**
 51:      * Retrieve table name for temporary bundle option stock index
 52:      *
 53:      * @return string
 54:      */
 55:     protected function _getBundleOptionTable()
 56:     {
 57:         return $this->getTable('bundle/stock_index');
 58:     }
 59: 
 60:     /**
 61:      * Prepare stock status per Bundle options, website and stock
 62:      *
 63:      * @param int|array $entityIds
 64:      * @param bool $usePrimaryTable use primary or temporary index table
 65:      * @return Mage_Bundle_Model_Resource_Indexer_Stock
 66:      */
 67:     protected function _prepareBundleOptionStockData($entityIds = null, $usePrimaryTable = false)
 68:     {
 69:         $this->_cleanBundleOptionStockData();
 70:         $idxTable = $usePrimaryTable ? $this->getMainTable() : $this->getIdxTable();
 71:         $adapter  = $this->_getWriteAdapter();
 72:         $select   = $adapter->select()
 73:             ->from(array('bo' => $this->getTable('bundle/option')), array('parent_id'));
 74:         $this->_addWebsiteJoinToSelect($select, false);
 75:         $status = new Zend_Db_Expr('MAX(' .
 76:                 $adapter->getCheckSql('e.required_options = 0', 'i.stock_status', '0') . ')');
 77:         $select->columns('website_id', 'cw')
 78:             ->join(
 79:                 array('cis' => $this->getTable('cataloginventory/stock')),
 80:                 '',
 81:                 array('stock_id')
 82:             )
 83:             ->joinLeft(
 84:                 array('bs' => $this->getTable('bundle/selection')),
 85:                 'bs.option_id = bo.option_id',
 86:                 array()
 87:             )
 88:             ->joinLeft(
 89:                 array('i' => $idxTable),
 90:                 'i.product_id = bs.product_id AND i.website_id = cw.website_id AND i.stock_id = cis.stock_id',
 91:                 array()
 92:             )
 93:             ->joinLeft(
 94:                 array('e' => $this->getTable('catalog/product')),
 95:                 'e.entity_id = bs.product_id',
 96:                 array()
 97:             )
 98:             ->where('cw.website_id != 0')
 99:             ->group(array('bo.parent_id', 'cw.website_id', 'cis.stock_id', 'bo.option_id'))
100:             ->columns(array(
101:                 'option_id' => 'bo.option_id',
102:                 'status'    => $status
103:             ));
104: 
105:         if (!is_null($entityIds)) {
106:             $select->where('bo.parent_id IN(?)', $entityIds);
107:         }
108: 
109:         // clone select for bundle product without required bundle options
110:         $selectNonRequired = clone $select;
111: 
112:         $select->where('bo.required = ?', 1);
113:         $selectNonRequired->where('bo.required = ?', 0)
114:             ->having($status . ' = 1');
115:         $query = $select->insertFromSelect($this->_getBundleOptionTable());
116:         $adapter->query($query);
117: 
118:         $query = $selectNonRequired->insertFromSelect($this->_getBundleOptionTable());
119:         $adapter->query($query);
120: 
121:         return $this;
122:     }
123: 
124:     /**
125:      * Get the select object for get stock status by product ids
126:      *
127:      * @param int|array $entityIds
128:      * @param bool $usePrimaryTable use primary or temporary index table
129:      * @return Varien_Db_Select
130:      */
131:     protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = false)
132:     {
133:         $this->_prepareBundleOptionStockData($entityIds, $usePrimaryTable);
134: 
135:         $adapter = $this->_getWriteAdapter();
136:         $select  = $adapter->select()
137:             ->from(array('e' => $this->getTable('catalog/product')), array('entity_id'));
138:         $this->_addWebsiteJoinToSelect($select, true);
139:         $this->_addProductWebsiteJoinToSelect($select, 'cw.website_id', 'e.entity_id');
140:         $select->columns('cw.website_id')
141:             ->join(
142:                 array('cis' => $this->getTable('cataloginventory/stock')),
143:                 '',
144:                 array('stock_id')
145:             )
146:             ->joinLeft(
147:                 array('cisi' => $this->getTable('cataloginventory/stock_item')),
148:                 'cisi.stock_id = cis.stock_id AND cisi.product_id = e.entity_id',
149:                 array()
150:             )
151:             ->joinLeft(
152:                 array('o' => $this->_getBundleOptionTable()),
153:                 'o.entity_id = e.entity_id AND o.website_id = cw.website_id AND o.stock_id = cis.stock_id',
154:                 array()
155:             )
156:             ->columns(array('qty' => new Zend_Db_Expr('0')))
157:             ->where('cw.website_id != 0')
158:             ->where('e.type_id = ?', $this->getTypeId())
159:             ->group(array('e.entity_id', 'cw.website_id', 'cis.stock_id'));
160: 
161:         // add limitation of status
162:         $condition = $adapter->quoteInto('=?', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
163:         $this->_addAttributeToSelect($select, 'status', 'e.entity_id', 'cs.store_id', $condition);
164: 
165:         if ($this->_isManageStock()) {
166:             $statusExpr = $adapter->getCheckSql(
167:                 'cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 0',
168:                 '1',
169:                 'cisi.is_in_stock'
170:             );
171:         } else {
172:             $statusExpr = $adapter->getCheckSql(
173:                 'cisi.use_config_manage_stock = 0 AND cisi.manage_stock = 1',
174:                 'cisi.is_in_stock',
175:                 '1'
176:             );
177:         }
178: 
179:         $select->columns(array('status' => $adapter->getLeastSql(array(
180:             new Zend_Db_Expr('MIN(' . $adapter->getCheckSql('o.stock_status IS NOT NULL','o.stock_status', '0') .')'),
181:             new Zend_Db_Expr('MIN(' . $statusExpr . ')'),
182:         ))));
183: 
184:         if (!is_null($entityIds)) {
185:             $select->where('e.entity_id IN(?)', $entityIds);
186:         }
187: 
188:         return $select;
189:     }
190: 
191:     /**
192:      * Prepare stock status data in temporary index table
193:      *
194:      * @param int|array $entityIds  the product limitation
195:      * @return Mage_Bundle_Model_Resource_Indexer_Stock
196:      */
197:     protected function _prepareIndexTable($entityIds = null)
198:     {
199:         parent::_prepareIndexTable($entityIds);
200:         $this->_cleanBundleOptionStockData();
201: 
202:         return $this;
203:     }
204: 
205:     /**
206:      * Update Stock status index by product ids
207:      *
208:      * @param array|int $entityIds
209:      * @return Mage_Bundle_Model_Resource_Indexer_Stock
210:      */
211:     protected function _updateIndex($entityIds)
212:     {
213:         parent::_updateIndex($entityIds);
214:         $this->_cleanBundleOptionStockData();
215: 
216:         return $this;
217:     }
218: 
219:     /**
220:      * Clean temporary bundle options stock data
221:      *
222:      * @return Mage_Bundle_Model_Resource_Indexer_Stock
223:      */
224:     protected function _cleanBundleOptionStockData()
225:     {
226:         $this->_getWriteAdapter()->delete($this->_getBundleOptionTable());
227:         return $this;
228:     }
229: }
230: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0