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 Options Resource Collection
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Bundle
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Bundle_Model_Resource_Option_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
 36: {
 37:     /**
 38:      * All item ids cache
 39:      *
 40:      * @var array
 41:      */
 42:     protected $_itemIds;
 43: 
 44:     /**
 45:      * True when selections a
 46:      *
 47:      * @var bool
 48:      */
 49:     protected $_selectionsAppended   = false;
 50: 
 51:     /**
 52:      * Init model and resource model
 53:      *
 54:      */
 55:     protected function _construct()
 56:     {
 57:         $this->_init('bundle/option');
 58:     }
 59: 
 60:     /**
 61:      * Joins values to options
 62:      *
 63:      * @param int $storeId
 64:      * @return Mage_Bundle_Model_Resource_Option_Collection
 65:      */
 66:     public function joinValues($storeId)
 67:     {
 68:         $this->getSelect()
 69:             ->joinLeft(
 70:                 array('option_value_default' => $this->getTable('bundle/option_value')),
 71:                 'main_table.option_id = option_value_default.option_id and option_value_default.store_id = 0',
 72:                 array()
 73:             )
 74:             ->columns(array('default_title' => 'option_value_default.title'));
 75: 
 76:         $title = $this->getConnection()->getCheckSql(
 77:             'option_value.title IS NOT NULL',
 78:             'option_value.title',
 79:             'option_value_default.title'
 80:         );
 81:         if ($storeId !== null) {
 82:             $this->getSelect()
 83:                 ->columns(array('title' => $title))
 84:                 ->joinLeft(array('option_value' => $this->getTable('bundle/option_value')),
 85:                     $this->getConnection()->quoteInto(
 86:                         'main_table.option_id = option_value.option_id and option_value.store_id = ?',
 87:                         $storeId
 88:                     ),
 89:                     array()
 90:                 );
 91:         }
 92:         return $this;
 93:     }
 94: 
 95:     /**
 96:      * Sets product id filter
 97:      *
 98:      * @param int $productId
 99:      * @return Mage_Bundle_Model_Resource_Option_Collection
100:      */
101:     public function setProductIdFilter($productId)
102:     {
103:         $this->addFieldToFilter('main_table.parent_id', $productId);
104:         return $this;
105:     }
106: 
107:     /**
108:      * Sets order by position
109:      *
110:      * @return Mage_Bundle_Model_Resource_Option_Collection
111:      */
112:     public function setPositionOrder()
113:     {
114:         $this->getSelect()->order('main_table.position asc')
115:             ->order('main_table.option_id asc');
116:         return $this;
117:     }
118: 
119:     /**
120:      * Append selection to options
121:      * stripBefore - indicates to reload
122:      * appendAll - indicates do we need to filter by saleable and required custom options
123:      *
124:      * @param Mage_Bundle_Model_Resource_Selection_Collection $selectionsCollection
125:      * @param bool $stripBefore
126:      * @param bool $appendAll
127:      * @return array
128:      */
129:     public function appendSelections($selectionsCollection, $stripBefore = false, $appendAll = true)
130:     {
131:         if ($stripBefore) {
132:             $this->_stripSelections();
133:         }
134: 
135:         if (!$this->_selectionsAppended) {
136:             foreach ($selectionsCollection->getItems() as $key => $_selection) {
137:                 if ($_option = $this->getItemById($_selection->getOptionId())) {
138:                     if ($appendAll || ($_selection->isSalable() && !$_selection->getRequiredOptions())) {
139:                         $_selection->setOption($_option);
140:                         $_option->addSelection($_selection);
141:                     } else {
142:                         $selectionsCollection->removeItemByKey($key);
143:                     }
144:                 }
145:             }
146:             $this->_selectionsAppended = true;
147:         }
148: 
149:         return $this->getItems();
150:     }
151: 
152:     /**
153:      * Removes appended selections before
154:      *
155:      * @return Mage_Bundle_Model_Resource_Option_Collection
156:      */
157:     protected function _stripSelections()
158:     {
159:         foreach ($this->getItems() as $option) {
160:             $option->setSelections(array());
161:         }
162:         $this->_selectionsAppended = false;
163:         return $this;
164:     }
165: 
166:     /**
167:      * Sets filter by option id
168:      *
169:      * @param array|int $ids
170:      * @return Mage_Bundle_Model_Resource_Option_Collection
171:      */
172:     public function setIdFilter($ids)
173:     {
174:         if (is_array($ids)) {
175:             $this->addFieldToFilter('main_table.option_id', array('in' => $ids));
176:         } else if ($ids != '') {
177:             $this->addFieldToFilter('main_table.option_id', $ids);
178:         }
179:         return $this;
180:     }
181: 
182:     /**
183:      * Reset all item ids cache
184:      *
185:      * @return Mage_Bundle_Model_Resource_Option_Collection
186:      */
187:     public function resetAllIds()
188:     {
189:         $this->_itemIds = null;
190:         return $this;
191:     }
192: 
193:     /**
194:      * Retrive all ids for collection
195:      *
196:      * @return array
197:      */
198:     public function getAllIds()
199:     {
200:         if (is_null($this->_itemIds)) {
201:             $this->_itemIds = parent::getAllIds();
202:         }
203:         return $this->_itemIds;
204:     }
205: }
206: 
207: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0