-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcat-list.php
executable file
·49 lines (40 loc) · 1.41 KB
/
cat-list.php
1
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/php
<?php
require_once 'lib/init.php';
/**
* "Website" is core/website
* "Store" is core/store_group
* "Store View" is core/store
*/
echo "List categories\n";
// if (is_null($parentId) && !is_null($store)) {
// $parentId = Mage::app()->getStore($this->_getStoreId($store))->getRootCategoryId();
// } elseif (is_null($parentId)) {
// $parentId = 1;
// }
$parentId = 1;
/* @var $tree Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree */
$tree = Mage::getResourceSingleton('catalog/category_tree')->load();
$root = $tree->getNodeById($parentId);
// if($root && $root->getId() == 1) {
// $root->setName(Mage::helper('catalog')->__('Root'));
// }
$collection = Mage::getModel('catalog/category')->getCollection()
// ->setStoreId($this->_getStoreId($store))
->addAttributeToSelect('*');
//->addAttributeToSelect('is_active');
$tree->addCollectionData($collection, true);
// A=active. C=anchor
function printCategory($cat, $prefix) {
/* @var $cat Mage_Catalog_Model_Category */
printf("%2d %s%s %-20s %-12s %s%s\n", $cat->getId(), $cat->getIsActive() ? 'A' : '-',
$cat->getIsAnchor() ? 'C' : '-',
$cat->getUrlKey(), $cat->getDefaultSortBy(), $prefix, $cat->getName() );
printf(" %-30s %-25s %s\n",
$cat->getMetaTitle(), $cat->getAvailableSortBy(), $cat->getDescription() );
//var_dump($cat);
foreach ($cat->getChildren() as $child) {
printCategory($child, '. '. $prefix);
}
}
printCategory($root, '');