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_Filters extends Mage_XmlConnect_Block_Catalog
35: {
36: 37: 38: 39: 40:
41: protected function _toHtml()
42: {
43: $categoryId = $this->getRequest()->getParam('category_id', null);
44: $categoryXmlObj = Mage::getModel('xmlconnect/simplexml_element', '<category></category>');
45: $filtersCollection = Mage::getResourceModel('xmlconnect/filter_collection')->setCategoryId($categoryId);
46:
47: $filtersXmlObj = $categoryXmlObj->addChild('filters');
48: foreach ($filtersCollection->getItems() as $item) {
49: if (!sizeof($item->getValues())) {
50: continue;
51: }
52: $itemXmlObj = $filtersXmlObj->addChild('item');
53: $itemXmlObj->addChild('name', $categoryXmlObj->escapeXml($item->getName()));
54: $itemXmlObj->addChild('code', $categoryXmlObj->escapeXml($item->getCode()));
55:
56: $valuesXmlObj = $itemXmlObj->addChild('values');
57: foreach ($item->getValues() as $value) {
58: $valueXmlObj = $valuesXmlObj->addChild('value');
59: $valueXmlObj->addChild('id', $categoryXmlObj->escapeXml($value->getValueString()));
60: $valueXmlObj->addChild('label', $categoryXmlObj->escapeXml($value->getLabel()));
61: $valueXmlObj->addChild('count', (int)$value->getProductsCount());
62: }
63: }
64: $categoryXmlObj->appendChild($this->getProductSortFeildsXmlObject());
65:
66: return $categoryXmlObj->asNiceXml();
67: }
68: }
69: