Example #1
0
 public function getCart($userId)
 {
     $result = DB::select()->from($this->tableName)->where('user', '=', $userId)->group_by('mid')->execute()->as_array();
     $material = new Model_Material('groups');
     $category = new Model_Category('tree');
     $base = new Model_Base();
     $arr = array();
     foreach ($result as $item) {
         //var_dump($item);
         //название модели
         $materialData = $material->getMaterial($item['mid']);
         $arr[$item['mid']]['name'] = $materialData['name'];
         $arr[$item['mid']]['mid'] = $item['mid'];
         //url модели
         $categoryName = $category->getNode($material->getTreeIdByMid($item['mid']));
         $categoryName = $base->str2url($categoryName['name']);
         $arr[$item['mid']]['url'] = $categoryName . '/' . $materialData['url'] . '.html';
         //Изображение
         $fields = $material->getFields($item['mid'], true);
         $arr[$item['mid']]['img'] = $fields['Photos'][0];
         //количество
         $arr[$item['mid']]['count'] = $this->getCartCount($userId, $item['mid']);
         //сумма
         $arr[$item['mid']]['sum'] = $this->getCartPrice($userId, $item['mid']);
         //размер
         $arr[$item['mid']]['size'] = $item['size'];
         //цвет
         $arr[$item['mid']]['color'] = $item['color'];
     }
     return $arr;
 }
Example #2
0
 public function getParentNode($mid)
 {
     $nodes = array();
     //получаем id группы
     $treeId = $this->getTreeIdByMid($mid);
     $category = new Model_Category('tree');
     $tree = $category->getNode($treeId);
     $nodes[] = $tree['url'];
     return implode('/', $nodes);
 }
Example #3
0
 public function action_graph($options = array("parent_id" => 4))
 {
     $this->setopt(array("name" => "parent_id", "description" => "Ид каталога", "default" => $options["parent_id"]));
     $parent_id = $this->getopt("parent_id");
     $model = array("items" => array());
     $model_tree = new Model_Widgets_Menu('tree');
     $category = new Model_Category('tree');
     $parent_node = $category->getNode($parent_id);
     $level = $parent_node["level"];
     //Получаем список меню
     $items = $model_tree->menuItems($parent_id, $level + 1);
     foreach ($items as $key => $item) {
         $this_category = $category->getCategory($category->getCategoryIdByUrl($item['url']));
         $category_id = $this_category['id'];
         $cat_photo = '/img/user/menu/' . $category_id . '_' . $item['url'];
         $cat_photo_path_jpg = $cat_photo . ".jpg";
         $cat_photo_path_png = $cat_photo . ".png";
         $cat_photo_path = "/img/noimg.png";
         if (file_exists(DOCROOT . $cat_photo_path_jpg)) {
             $cat_photo_path = $cat_photo_path_jpg;
         } elseif (file_exists(DOCROOT . $cat_photo_path_png)) {
             $cat_photo_path = $cat_photo_path_png;
         }
         $model["items"][] = array("href" => "/" . $item["parent"] . "/" . $item["url"], "photo" => Route::url('miniimg3', array('filename' => $cat_photo_path)), "name" => $item["name"]);
     }
     $this->set_template("widgets/menu/graph.php", "twig")->render($model)->body();
 }