*/ class Mage_XmlConnect_Block_Home extends Mage_XmlConnect_Block_Catalog { /** * Category list limitation */ const HOME_PAGE_CATEGORIES_COUNT = 6; /** * Render home category list xml * * @return string */ protected function _toHtml() { /** @var $homeXmlObj Mage_XmlConnect_Model_Simplexml_Element */ $homeXmlObj = Mage::getModel('xmlconnect/simplexml_element', ''); $categoryCollection = array(); $helper = Mage::helper('catalog/category'); $categoryCount = 0; foreach ($helper->getStoreCategories() as $child) { if ($child->getIsActive()) { $categoryCollection[] = $child; $categoryCount++; } if ($categoryCount == self::HOME_PAGE_CATEGORIES_COUNT) { break; } } if (sizeof($categoryCollection)) { $itemsXmlObj = $homeXmlObj->addChild('categories'); } foreach ($categoryCollection as $item) { /** @var $item Mage_Catalog_Model_Category */ $item = Mage::getModel('catalog/category')->load($item->getId()); if (!$item->getIncludeInMenu()) { continue; } $itemXmlObj = $itemsXmlObj->addChild('item'); $itemXmlObj->addChild('label', $homeXmlObj->escapeXml($item->getName())); $itemXmlObj->addChild('entity_id', $item->getId()); $itemXmlObj->addChild('content_type', $item->hasChildren() ? 'categories' : 'products'); $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail') ->resize(Mage::getModel('xmlconnect/images')->getImageLimitParam('content/category')); $iconXml = $itemXmlObj->addChild('icon', $icon); $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile())); } $homeXmlObj->addChild('home_banner', '/current/media/catalog/category/banner_home.png'); return $homeXmlObj->asNiceXml(); } }