This repository was archived by the owner on Jun 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Module_Categories
Nikolay Galkin edited this page Jun 7, 2013
·
2 revisions
Менеджер каталога должен быть универсальным, чтобы можно было использовать его в любом модуле
- id
- alias
- title
- description
- parentId
- level
- path
- created Дата создания
- updated Дата последнего изменения
Categories_Model_Category_Table extends Core_Db_Table_Abstract Categories_Model_Category::loadTree - загрузить(аля закешировать) все дочерние элементы и построить дерево Categories_Model_Category::addChild - добавить категорию в дочерние к текущей Categories_Model_Category::getAllChildren - вытащить все дочерние элементы ввиде списка (Rowset)
$categories = new Core_Categories_Table();
$category = $categories->getById(1);
$category->loadTree(); // if called then it will load all items in single request and each getChildren() method would not invoke db
$result = array();
foreach ($category->getChildren() as $row) {
$result[$row->id] = $row->toArray();
foreach ($row->getChildren() as $subrow) {
$result[$row->id]['children'][$subrow->id] = $subrow->toArray();
foreach ($subrow->getChildren() as $subsubrow) {
$result[$row->id]['children'][$subrow->id]['children'][$subsubrow->id] = $subsubrow->toArray();
}
}
}