Public Member Functions | |
getOptions () | |
hasOptions () | |
getJsonConfig () | |
addRenderer ($type, $block) | |
getOptionHtml ($option) | |
Protected Attributes | |
$_optionRenderers = array() | |
$_options = null |
Definition at line 35 of file Bundle.php.
addRenderer | ( | $ | type, | |
$ | block | |||
) |
getJsonConfig | ( | ) |
Definition at line 66 of file Bundle.php.
00067 { 00068 Mage::app()->getLocale()->getJsPriceFormat(); 00069 $store = Mage::app()->getStore(); 00070 $optionsArray = $this->getOptions(); 00071 $options = array(); 00072 $selected = array(); 00073 00074 foreach ($optionsArray as $_option) { 00075 if (!$_option->getSelections()) { 00076 continue; 00077 } 00078 $option = array ( 00079 'selections' => array(), 00080 'title' => $_option->getTitle(), 00081 'isMulti' => ($_option->getType() == 'multi' || $_option->getType() == 'checkbox') 00082 ); 00083 00084 $selectionCount = count($_option->getSelections()); 00085 00086 foreach ($_option->getSelections() as $_selection) { 00087 $_qty = !($_selection->getSelectionQty()*1)?'1':$_selection->getSelectionQty()*1; 00088 $selection = array ( 00089 'qty' => $_qty, 00090 'customQty' => $_selection->getSelectionCanChangeQty(), 00091 'price' => Mage::helper('core')->currency($_selection->getFinalPrice(), false, false), 00092 'priceValue' => Mage::helper('core')->currency($_selection->getSelectionPriceValue(), false, false), 00093 'priceType' => $_selection->getSelectionPriceType(), 00094 'tierPrice' => $_selection->getTierPrice(), 00095 'name' => $_selection->getName(), 00096 'plusDisposition' => 0, 00097 'minusDisposition' => 0, 00098 ); 00099 $responseObject = new Varien_Object(); 00100 $args = array('response_object'=>$responseObject, 'selection'=>$_selection); 00101 Mage::dispatchEvent('bundle_product_view_config', $args); 00102 if (is_array($responseObject->getAdditionalOptions())) { 00103 foreach ($responseObject->getAdditionalOptions() as $o=>$v) { 00104 $selection[$o] = $v; 00105 } 00106 } 00107 $option['selections'][$_selection->getSelectionId()] = $selection; 00108 00109 if (($_selection->getIsDefault() || ($selectionCount == 1 && $_option->getRequired())) && $_selection->isSalable()) { 00110 $selected[$_option->getId()][] = $_selection->getSelectionId(); 00111 } 00112 } 00113 $options[$_option->getId()] = $option; 00114 } 00115 00116 $config = array( 00117 'options' => $options, 00118 'selected' => $selected, 00119 'bundleId' => $this->getProduct()->getId(), 00120 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), 00121 'basePrice' => Mage::helper('core')->currency($this->getProduct()->getPrice(), false, false), 00122 'priceType' => $this->getProduct()->getPriceType(), 00123 'specialPrice' => $this->getProduct()->getSpecialPrice() 00124 ); 00125 00126 return Zend_Json::encode($config); 00127 }
getOptionHtml | ( | $ | option | ) |
Definition at line 134 of file Bundle.php.
00135 { 00136 if (!isset($this->_optionRenderers[$option->getType()])) { 00137 return $this->__('There is no defined renderer for "%s" option type', $option->getType()); 00138 } 00139 return $this->getLayout()->createBlock($this->_optionRenderers[$option->getType()]) 00140 ->setOption($option)->toHtml(); 00141 }
getOptions | ( | ) |
Definition at line 40 of file Bundle.php.
00041 { 00042 if (!$this->_options) { 00043 $this->getProduct()->getTypeInstance(true)->setStoreFilter($this->getProduct()->getStoreId(), $this->getProduct()); 00044 00045 $optionCollection = $this->getProduct()->getTypeInstance(true)->getOptionsCollection($this->getProduct()); 00046 00047 $selectionCollection = $this->getProduct()->getTypeInstance(true)->getSelectionsCollection( 00048 $this->getProduct()->getTypeInstance(true)->getOptionsIds($this->getProduct()), 00049 $this->getProduct() 00050 ); 00051 00052 $this->_options = $optionCollection->appendSelections($selectionCollection, false, false); 00053 } 00054 return $this->_options; 00055 }
hasOptions | ( | ) |
Definition at line 57 of file Bundle.php.
00058 { 00059 $this->getOptions(); 00060 if (empty($this->_options) || !$this->getProduct()->isSalable()) { 00061 return false; 00062 } 00063 return true; 00064 }
$_optionRenderers = array() [protected] |
Definition at line 37 of file Bundle.php.
$_options = null [protected] |
Definition at line 38 of file Bundle.php.