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_Grouped 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 = Mage::getModel('xmlconnect/simplexml_element', '<product></product>');
46: $optionsNode = $xmlModel->addChild('options');
47:
48: if (!$product->getId()) {
49: return $isObject ? $xmlModel : $xmlModel->asNiceXml();
50: }
51: $xmlModel->addAttribute('id', $product->getId());
52: if (!$product->isSaleable()) {
53: return $isObject ? $xmlModel : $xmlModel->asNiceXml();
54: }
55: 56: 57:
58: $_associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
59: if (!sizeof($_associatedProducts)) {
60: return $isObject ? $xmlModel : $xmlModel->asNiceXml();
61: }
62:
63: foreach ($_associatedProducts as $_item) {
64: if (!$_item->isSaleable()) {
65: continue;
66: }
67: $optionNode = $optionsNode->addChild('option');
68:
69: $optionNode->addAttribute('code', 'super_group[' . $_item->getId() . ']');
70: $optionNode->addAttribute('type', 'product');
71: $optionNode->addAttribute('label', $xmlModel->escapeXml($_item->getName()));
72: $optionNode->addAttribute('is_qty_editable', 1);
73: $optionNode->addAttribute('qty', $_item->getQty()*1);
74:
75: 76: 77:
78: if ($_item->getPrice() != $_item->getFinalPrice()) {
79: $productPrice = $_item->getFinalPrice();
80: } else {
81: $productPrice = $_item->getPrice();
82: }
83:
84: if ($productPrice != 0) {
85: $productPrice = Mage::helper('xmlconnect')->formatPriceForXml($productPrice);
86: $optionNode->addAttribute('price', Mage::helper('xmlconnect')->formatPriceForXml(
87: Mage::helper('core')->currency($productPrice, false, false)
88: ));
89: $optionNode->addAttribute('formated_price', $this->_formatPriceString($productPrice, $product));
90: }
91: }
92:
93: return $isObject ? $xmlModel : $xmlModel->asNiceXml();
94: }
95: }
96: