/** get Catalogue Item * @param $path * @return array */ private function getCatalogueItem($path) { $data = array(); $path_items = CatalogueUtils::getPathItems($path); $catalogue = array(); $catalogue["path_items"] = $path_items; $last = count($path) - 1; $catalogue["current_label"] = $path[$last]; /* * // prev item categories list * $arr = $this->address["path"]; array_pop($arr); $catalogue["prev_item_path"] = implode("/", $arr); $pre_last = count($this->address["path"]) - 2; if ($pre_last >= 0){ $childrenId = $path_items[$pre_last]["children_id"]; $current_categories = CatalogueUtils::getProducts($childrenId); } */ if (count($path) > 1) { $childrenId = $path_items[0]["children_id"]; $current_categories = CatalogueUtils::getProducts($childrenId); G::addToRender("blocks/sidebar_navigation.php", BLOCK_SIDEBAR_LEFT, CODE); } else { G::addToRender("<h1>" . G::$language->getText("common", "catalogue_link_text") . "</h1>", BLOCK_CONTENT); } $childrenId = $path_items[$last]["children_id"]; $products = array(); if ($path_items[$last]["type"] != TYPE_CATEGORY) { // single product $node = CatalogueUtils::getCatalogueNode($path_items[$last]["label"]); $current_product = new ProductItem($node); # required class ProductItem $data = $this->parsePageData($node); // "if hidden" HERE because - admin mode should load data of hidden elements if (!$path_items[$last]["hidden"]) { G::addToRender("catalogue/catalogue_single_product.php", BLOCK_CONTENT, CODE); G::addToRender("blocks/brand_block.php", BLOCK_SIDEBAR_RIGHT, CODE); } else { //$this->redirect(PAGE_PAGE404); when not AJAX $message = "<p class='grey-text' align='center'>" . G::$language->getText("catalogue", "category_fail") . "</p>"; G::addToRender($message, BLOCK_CONTENT); } } else { $node = CatalogueUtils::getCatalogueNode($path_items[$last]["label"]); $current_product = new ProductItem($node); $data = $this->parsePageData($node); if (strlen($childrenId) > 0) { //multiple categories|products $total = count(explode(",", $childrenId)); $page = intval($_GET["page"]); $items_limit = isset($_SESSION["page_items_limit"]) ? $_SESSION["page_items_limit"] : Paginator::PAGE_ITEMS_LIMIT; $max_pages = ceil($total / $items_limit); if ($page > $max_pages) { $_GET["page"] = $page = $max_pages; } if ($total > $_SESSION["page_items_limit"]) { $paginator = new Paginator($max_pages, $page); G::addToRender($paginator->render(), BLOCK_CONTENT, TEXT); } $products = CatalogueUtils::getProducts($childrenId, $_SESSION["page_items_limit"], $page); } if ($products && count($products) > 0) { G::addToRender("catalogue/catalogue_page_blocks.php", BLOCK_CONTENT, CODE); // die("HERE:".count($products)); } else { // no products in category $message = "<p class='grey-text' align='center'>" . G::$language->getText("common", "empty_category") . "</p>"; G::addToRender($message, BLOCK_CONTENT); } } $data["current_categories"] = $current_categories; $data["catalogue"] = $catalogue; $data["products"] = $products; $data["current_product"] = $current_product; // DEBUG $data["access"] = 4; if (!isset($data["title"])) { $data["title"] = G::$language->getText("common", "catalogue_link_text"); } $data["blocks_id"] = "1,3,4,5,6,7,8,9,10,11,12,15"; // return $data; }