OpenCart
- 1 ответ
- 0 вопросов
1
Вклад в тег
catalog\model\catalog\product.php
новую функцию// получение пути шаблона
public function getProductLayoutRoute($layout_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout_route WHERE layout_id = '" . (int)$layout_id . "'");
if ($query->num_rows) {
return $query->row['route'];
} else {
return "";
}
}
catalog\controller\product\product.php
строку$this->response->setOutput($this->load->view('product/product', $data));
$layout_id = $this->model_catalog_product->getProductLayoutId($product_id);
if($layout_id) {
$route = $this->model_catalog_product->getProductLayoutRoute($layout_id);
// проверяем существование файла шаблона
$filepath = DIR_TEMPLATE . $this->config->get('config_theme') . '/template/' . $route . '.tpl';
if(file_exists($filepath)) {
$this->response->setOutput($this->load->view($route, $data));
} else {
$this->response->setOutput($this->load->view('product/product', $data));
}
} else {
$this->response->setOutput($this->load->view('product/product', $data));
}