/** * Frontend shop product page */ public function dispShopProduct() { /** @var $product Product */ if ($product = Context::get('product')) { //came from from routing if (!($product instanceof Product) || !$product->isPersisted()) throw new ShopException('Wrong product'); } else { if (!$product_srl = Context::get('product_srl')) throw new ShopException('Could not identify product'); $product_repository = new ProductRepository(); $product = $product_repository->getProduct($product_srl); if (!$product instanceof Product) throw new ShopException('Product does not exist'); Context::set('product', $product); } //add product document if it does not exist (link to comments) if(!isset($product->document_srl)){ $documentController = getController('document'); $document = new stdClass(); $document->title = $product->product_srl; $document->commentStatus = 'ALLOW'; $document->module_srl = $product->module_srl; $output = $documentController->insertDocument($document); $product->document_srl = $output->variables['document_srl']; unset($product->images); $product->repo->updateProduct($product); } $documentModel = getModel('document'); $product->document = $documentModel->getDocument($product->document_srl); $product->comment_list = $_comment_list = $product->document->getComments(); if (is_array($_comment_list)) { foreach ($product->comment_list as $comment){ $comment->variables['relativeDate'] = $this->model->zdateRelative($comment->getRegdateTime()); } } // Setup Javscript datasource for linked dropdowns $datasourceJS = $this->getAssociatedProductsAttributesAsJavascriptArray(array($product)); Context::set('datasourceJS', $datasourceJS); // Setup attributes names for display if(count($product->attributes)) { $attribute_repository = new AttributeRepository(); $attributes = $attribute_repository->getAttributes(array_keys($product->attributes)); Context::set('attributes', $attributes); } // Categories left tree // Retrieve existing categories $category_repository = new CategoryRepository(); $tree = $category_repository->getNavigationCategoriesTree($this->module_srl); // Prepare tree for display $tree_config = new HtmlCategoryTreeConfig(); $tree_config->linkCategoryName = TRUE; $tree_config->linkGetUrlParams = array('vid', $this->mid, 'act', 'dispShop'); $tree_config->selected = $product->categories; $HTML_tree = $tree->toHTML($tree_config); Context::set('HTML_tree', $HTML_tree); $this->loadShopCategoryTree(); $this->setTemplateFile('product.html'); }