I've come across a bug that occurs when you pass parameters of a bundled product into a wishlist. The initial issue isn't adding the bundled product into the wishlist it occurs when you add to basket from the wishlist with one of the simple product. If the product becomes out of stock between the user adding the bundle to their wishlist and the product is added to basket a fatal error is triggered:
FATAL ERROR: CALL TO A MEMBER FUNCTION GETSELECTIONQTY() ON A NON-OBJECT IN
/APP/CODE/CORE/MAGE/BUNDLE/BLOCK/CATALOG/PRODUCT/VIEW/TYPE/BUNDLE/OPTION.PHP ON LINE 88
Magento seems to make the assumption that the object creation is always going to be successful resulting on a Non-Object error.
It seems that the method Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option::_getDefaultValues
assume that all the
/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php
protected function _getDefaultValues()
{
$_option = $this->getOption();
$_default = $_option->getDefaultSelection();
$_selections = $_option->getSelections();
$selectedOptions = $this->_getSelectedOptions();
$inPreConfigured = $this->getProduct()->hasPreconfiguredValues()
&& $this->getProduct()->getPreconfiguredValues()
->getData('bundle_option_qty/' . $_option->getId());
if (empty($selectedOptions) && $_default) {
$_defaultQty = $_default->getSelectionQty()*1;
$_canChangeQty = $_default->getSelectionCanChangeQty();
} elseif (!$inPreConfigured && $selectedOptions && is_numeric($selectedOptions)) {
$selectedSelection = $_option->getSelectionById($selectedOptions);
$_defaultQty = $selectedSelection->getSelectionQty()*1; //Line 88
$_canChangeQty = $selectedSelection->getSelectionCanChangeQty();
} elseif (!$this->_showSingle() || $inPreConfigured) {
$_defaultQty = $this->_getSelectedQty();
$_canChangeQty = (bool)$_defaultQty;
} else {
$_defaultQty = $_selections[0]->getSelectionQty()*1;
$_canChangeQty = $_selections[0]->getSelectionCanChangeQty();
}
return array($_defaultQty, $_canChangeQty);
}
Replication steps:
- Add a bundled product with options to the wishlist.
- Remove one of the simple products from stock with backorders disabled
- Add the item to the basket from the wishlist
Result:
FATAL ERROR: CALL TO A MEMBER FUNCTION GETSELECTIONQTY() ON A NON-OBJECT IN
/APP/CODE/CORE/MAGE/BUNDLE/BLOCK/CATALOG/PRODUCT/VIEW/TYPE/BUNDLE/OPTION.PHP ON LINE 88
Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option->_getDefaultValues()
URL: <domain>/wishlist/index/configure/id/<id>/
( ! ) FATAL ERROR: CALL TO A MEMBER FUNCTION GETSELECTIONQTY() ON A NON-OBJECT IN /APP/CODE/CORE/MAGE/BUNDLE/BLOCK/CATALOG/PRODUCT/VIEW/TYPE/BUNDLE/OPTION.PHP ON LINE 88
CALL STACK
# TIME MEMORY FUNCTION LOCATION
1 0.0000 635120 {main}( ) ../index.php:0
2 0.0022 687320 Mage::run( ) ../index.php:95
3 0.0032 959944 Mage_Core_Model_App->run( ) ../Mage.php:683
4 1.9203 5411184 Mage_Core_Controller_Varien_Front->dispatch( ) ../App.php:354
5 1.9238 5574992 Mage_Core_Controller_Varien_Router_Standard->match( ) ../Front.php:176
6 1.9262 5763440 Mage_Core_Controller_Varien_Action->dispatch( ) ../Standard.php:250
7 2.0631 9195512 Mage_Wishlist_IndexController->configureAction( ) ../Action.php:419
8 2.0737 9577736 Mage_Catalog_Helper_Product_View->prepareAndRender( ) ../IndexController.php:260
9 2.7699 22976864 Mage_Core_Controller_Varien_Action->renderLayout( ) ../View.php:147
10 2.7754 23331416 Mage_Core_Model_Layout->getOutput( ) ../Action.php:390
11 2.7754 23331496 Mage_Core_Block_Abstract->toHtml( ) ../Layout.php:555
12 2.7758 23333752 Mage_Core_Block_Template->_toHtml( ) ../Abstract.php:863
13 2.7758 23333752 Mage_Core_Block_Template->renderView( ) ../Template.php:286
14 2.7766 23334440 Mage_Core_Block_Template->fetchView( ) ../Template.php:272
15 2.7770 23377008 include( '/app/design/frontend/mytheme/default/template/page/1column.phtml' ) ../Template.php:241
16 3.1325 25998040 Mage_Core_Block_Abstract->getChildHtml( ) ../1column.phtml:36
17 3.1325 25998136 Mage_Core_Block_Abstract->_getChildHtml( ) ../Abstract.php:526
18 3.1325 25998136 Mage_Core_Block_Abstract->toHtml( ) ../Abstract.php:582
19 3.1328 25998368 Mage_Core_Block_Text_List->_toHtml( ) ../Abstract.php:863
20 3.1328 25998544 Mage_Core_Block_Abstract->toHtml( ) ../List.php:43
21 3.1331 25998776 Mage_Core_Block_Template->_toHtml( ) ../Abstract.php:863
22 3.1332 25998776 Mage_Core_Block_Template->renderView( ) ../Template.php:286
23 3.1335 25998912 Mage_Core_Block_Template->fetchView( ) ../Template.php:272
24 3.1336 26042136 include( '/app/design/frontend/mytheme/default/template/bundle/catalog/product/view.phtml' ) ../Template.php:241
25 3.2990 27927384 Mage_Core_Block_Abstract->getChildChildHtml( ) ../view.phtml:108
26 3.2990 27927560 Mage_Core_Block_Abstract->getChildHtml( ) ../Abstract.php:546
27 3.2990 27928104 Mage_Core_Block_Abstract->_getChildHtml( ) ../Abstract.php:522
28 3.2990 27928104 Mage_Core_Block_Abstract->toHtml( ) ../Abstract.php:582
29 3.2993 27928336 Mage_Core_Block_Template->_toHtml( ) ../Abstract.php:863
30 3.2993 27928336 Mage_Core_Block_Template->renderView( ) ../Template.php:286
31 3.2997 27928480 Mage_Core_Block_Template->fetchView( ) ../Template.php:272
32 3.2998 27971192 include( '/app/design/frontend/mytheme/default/template/catalog/product/view/options/wrapper.phtml' ) ../Template.php:241
33 3.2998 27971368 Mage_Core_Block_Abstract->getChildHtml( ) ../wrapper.phtml:12
34 3.2999 27972352 Mage_Core_Block_Abstract->_getChildHtml( ) ../Abstract.php:522
35 3.2999 27972352 Mage_Core_Block_Abstract->toHtml( ) ../Abstract.php:582
36 3.3002 27972584 Mage_Core_Block_Template->_toHtml( ) ../Abstract.php:863
37 3.3002 27972584 Mage_Core_Block_Template->renderView( ) ../Template.php:286
38 3.3005 27972736 Mage_Core_Block_Template->fetchView( ) ../Template.php:272
39 3.3006 28015480 include( '/app/design/frontend/mytheme/default/template/bundle/catalog/product/view/type/bundle/options.phtml' ) ../Template.php:241
40 3.3158 28030168 Mage_Bundle_Block_Catalog_Product_View_Type_Bundle->getOptionHtml( ) ../options.phtml:38
41 3.3194 28396208 Mage_Core_Block_Abstract->toHtml( ) ../Bundle.php:216
42 3.3199 28396440 Mage_Bundle_Block_Catalog_Product_Price->_toHtml( ) ../Abstract.php:863
43 3.3200 28396720 Mage_Catalog_Block_Product_Price->_toHtml( ) ../Price.php:97
44 3.3201 28396904 Mage_Core_Block_Template->_toHtml( ) ../Price.php:154
45 3.3201 28396904 Mage_Core_Block_Template->renderView( ) ../Template.php:286
46 3.3205 28397064 Mage_Core_Block_Template->fetchView( ) ../Template.php:272
47 3.3207 28439808 include( '/app/design/frontend/mytheme/default/template/bundle/catalog/product/view/type/bundle/option/select.phtml' ) ../Template.php:241
48 3.3209 28440720 Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option->_getDefaultValues( )