I'm trying to add a custom menu on the header of opencart 2.3, tried different options even tried this one from stack opencart Adding a custom menu in the header menu But had no success, i found this code in Opencart forum it supposed to be placed in the header.php file:
$this->load->model('catalog/product');
$products_1 = $this->model_catalog_product->getProducts($data = array());
if ($products_1) {$output = '<ul id="topnav">';}
foreach ($products_1 as $product_1) {
$output .= '<li>';
$unrewritten = $this->url->link('product/product', 'product_id=' . $product_1['product_id']);
$output .= '<a href="'.($unrewritten).'">' . $product_1['model'] . '</a>';
}
if ($products_1) {$output .= '</ul>';}
echo $output;
?>
更具体地说,您需要编辑controller / common / header.php以包括在view / theme /(您的主题)/common/header.tpl中未定义的变量
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.