Public Member Functions | |
bindPager ($pagerName) | |
prepareCategoriesToPages () | |
getTreeCollection () | |
getLevel ($item, $delta=1) | |
Public Attributes | |
CONST | XML_PATH_LINES_PER_PAGE = 'catalog/sitemap/lines_perpage' |
Protected Member Functions | |
_prepareLayout () | |
_prepareCollection () | |
Protected Attributes | |
$_storeRootCategoryPath = '' | |
$_storeRootCategoryLevel = 0 | |
$_total = 0 | |
$_from = 0 | |
$_to = 0 | |
$_currentPage = 0 | |
$_categoriesToPages = array() |
Definition at line 35 of file Category.php.
_prepareCollection | ( | ) | [protected] |
Prepare collection filtered by paths
Definition at line 148 of file Category.php.
00149 { 00150 $_to = 0; 00151 $pathFilter = array(); 00152 if (isset($this->_categoriesToPages[$this->_currentPage])) { 00153 foreach ($this->_categoriesToPages[$this->_currentPage] as $_categoryId=>$_categoryInfo) { 00154 $pathFilter[] = $_categoryInfo['path']; 00155 $_to = max($_to, $_categoryInfo['children_count']); 00156 } 00157 } 00158 if (empty($pathFilter)) { 00159 $pathFilter = $this->_storeRootCategoryPath . '/'; 00160 } 00161 $collection = $this->getCollection(); 00162 $collection->addPathsFilter($pathFilter); 00163 $this->_to = $_to; 00164 $this->_from = $_to - $collection->count(); 00165 return $this; 00166 }
_prepareLayout | ( | ) | [protected] |
Initialize categories collection
Reimplemented from Mage_Catalog_Block_Seo_Sitemap_Category.
Definition at line 51 of file Category.php.
00052 { 00053 $helper = Mage::helper('catalog/category'); 00054 /* @var $helper Mage_Catalog_Helper_Category */ 00055 $parent = Mage::getModel('catalog/category') 00056 ->setStoreId(Mage::app()->getStore()->getId()) 00057 ->load(Mage::app()->getStore()->getRootCategoryId()); 00058 $this->_storeRootCategoryPath = $parent->getPath(); 00059 $this->_storeRootCategoryLevel = $parent->getLevel(); 00060 $this->prepareCategoriesToPages(); 00061 $collection = $this->getTreeCollection(); 00062 $this->setCollection($collection); 00063 return $this; 00064 }
bindPager | ( | $ | pagerName | ) |
Init pager
string | $pagerName |
Reimplemented from Mage_Catalog_Block_Seo_Sitemap_Abstract.
Definition at line 71 of file Category.php.
00072 { 00073 $pager = $this->getLayout()->getBlock($pagerName); 00074 /* @var $pager Mage_Catalog_Block_Seo_Sitemap_Tree_Pager */ 00075 if ($pager) { 00076 $pager->setAvailableLimit(array(50 => 50)); 00077 $pager->setTotalNum($this->_total); 00078 $pager->setLastPageNum(count($this->_categoriesToPages)); 00079 if (!$this->_currentPage) { 00080 $this->_currentPage = $pager->getCurrentPage(); 00081 $this->_prepareCollection(); 00082 } 00083 $pager->setFirstNum($this->_from); 00084 $pager->setLastNum($this->_to); 00085 $pager->setCollection($this->getCollection()); 00086 $pager->setShowPerPage(false); 00087 } 00088 }
getLevel | ( | $ | item, | |
$ | delta = 1 | |||
) |
Return level of indent
Mage_Catalog_Model_Category | $item | |
integer | $delta |
Definition at line 175 of file Category.php.
00176 { 00177 return (int) ($item->getLevel() - $this->_storeRootCategoryLevel - 1) * $delta; 00178 }
getTreeCollection | ( | ) |
Return collection of categories
Definition at line 133 of file Category.php.
00134 { 00135 $collection = Mage::getModel('catalog/category')->getCollection() 00136 ->addNameToResult() 00137 ->addUrlRewriteToResult() 00138 ->addIsActiveFilter() 00139 ->addOrderField('path'); 00140 return $collection; 00141 }
prepareCategoriesToPages | ( | ) |
Prepare array of categories separated into pages
Definition at line 95 of file Category.php.
00096 { 00097 $linesPerPage = Mage::getStoreConfig(self::XML_PATH_LINES_PER_PAGE); 00098 $tmpCollection = Mage::getModel('catalog/category')->getCollection() 00099 ->addIsActiveFilter() 00100 ->addPathsFilter($this->_storeRootCategoryPath . '/') 00101 ->addLevelFilter($this->_storeRootCategoryLevel + 1) 00102 ->addOrderField('path'); 00103 $count = 0; 00104 $page = 1; 00105 $categories = array(); 00106 foreach ($tmpCollection as $item) { 00107 $children = $item->getChildrenCount()+1; 00108 $this->_total += $children; 00109 if (($children+$count) >= $linesPerPage) { 00110 $categories[$page][$item->getId()] = array( 00111 'path' => $item->getPath(), 00112 'children_count' => $this->_total 00113 ); 00114 $page++; 00115 $count = 0; 00116 continue; 00117 } 00118 $categories[$page][$item->getId()] = array( 00119 'path' => $item->getPath(), 00120 'children_count' => $this->_total 00121 ); 00122 $count += $children; 00123 } 00124 $this->_categoriesToPages = $categories; 00125 return $this; 00126 }
$_categoriesToPages = array() [protected] |
Definition at line 45 of file Category.php.
$_currentPage = 0 [protected] |
Definition at line 44 of file Category.php.
$_from = 0 [protected] |
Definition at line 42 of file Category.php.
$_storeRootCategoryLevel = 0 [protected] |
Definition at line 40 of file Category.php.
$_storeRootCategoryPath = '' [protected] |
Definition at line 39 of file Category.php.
$_to = 0 [protected] |
Definition at line 43 of file Category.php.
$_total = 0 [protected] |
Definition at line 41 of file Category.php.
CONST XML_PATH_LINES_PER_PAGE = 'catalog/sitemap/lines_perpage' |
Definition at line 37 of file Category.php.