1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_XmlConnect_Block_Catalog_Product_Options_Bundle extends Mage_XmlConnect_Block_Catalog_Product_Options
35: {
36: 37: 38: 39: 40: 41: 42:
43: public function getProductOptionsXml(Mage_Catalog_Model_Product $product, $isObject = false)
44: {
45: $xmlModel = $this->getProductCustomOptionsXmlObject($product);
46: $optionsXmlObj = $xmlModel->options;
47:
48: if (!$product->isSaleable()) {
49: return $isObject ? $xmlModel : $xmlModel->asNiceXml();
50: }
51:
52: 53: 54:
55: $product->getTypeInstance(true)->setStoreFilter($product->getStoreId(), $product);
56: $optionCollection = $product->getTypeInstance(true)->getOptionsCollection($product);
57: $selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
58: $product->getTypeInstance(true)->getOptionsIds($product), $product
59: );
60: $bundleOptions = $optionCollection->appendSelections($selectionCollection, false, false);
61: if (!sizeof($bundleOptions)) {
62: return $isObject ? $xmlModel : $xmlModel->asNiceXml();
63: }
64:
65: foreach ($bundleOptions as $_option) {
66: $selections = $_option->getSelections();
67: if (empty($selections)) {
68: continue;
69: }
70:
71: $optionNode = $optionsXmlObj->addChild('option');
72:
73: $type = parent::OPTION_TYPE_SELECT;
74: if ($_option->isMultiSelection()) {
75: $type = parent::OPTION_TYPE_CHECKBOX;
76: }
77: $code = 'bundle_option[' . $_option->getId() . ']';
78: if ($type == parent::OPTION_TYPE_CHECKBOX) {
79: $code .= '[]';
80: }
81: $optionNode->addAttribute('code', $code);
82: $optionNode->addAttribute('type', $type);
83: $optionNode->addAttribute('label', $optionsXmlObj->escapeXml($_option->getTitle()));
84: if ($_option->getRequired()) {
85: $optionNode->addAttribute('is_required', 1);
86: }
87:
88: foreach ($selections as $_selection) {
89: if (!$_selection->isSaleable()) {
90: continue;
91: }
92: $_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1;
93:
94: $valueNode = $optionNode->addChild('value');
95: $valueNode->addAttribute('code', $_selection->getSelectionId());
96: $valueNode->addAttribute('label', $optionsXmlObj->escapeXml($_selection->getName()));
97: if (!$_option->isMultiSelection()) {
98: if ($_selection->getSelectionCanChangeQty()) {
99: $valueNode->addAttribute('is_qty_editable', 1);
100: }
101: }
102: $valueNode->addAttribute('qty', $_qty);
103:
104: $price = $product->getPriceModel()->getSelectionPreFinalPrice($product, $_selection);
105: $price = Mage::helper('xmlconnect')->formatPriceForXml($price);
106: if ((float)$price != 0.00) {
107: $valueNode->addAttribute('price', Mage::helper('xmlconnect')->formatPriceForXml(
108: Mage::helper('core')->currency($price, false, false)
109: ));
110: $valueNode->addAttribute('formated_price', $this->_formatPriceString($price, $product));
111: }
112: }
113: }
114:
115: return $isObject ? $xmlModel : $xmlModel->asNiceXml();
116: }
117: }
118: