如何将新模块添加到opencart管理?

时间:2012-06-10 19:48:54

标签: php opencart

我想在opencart管理中的“目录”菜单项中添加子菜单项“位置”。在选择位置时,我想看到我自己的位置管理视图页面,它在opencart数据库中使用我自己的位置表进行了减少。

请让我知道要在开放式购物车中创建此功能的mvc的位置和内容。 谢谢。

2 个答案:

答案 0 :(得分:6)

如何创建一个opencart管理模块?

你可以通过调整:

来做到这一点
Admin > controller > view > template > common > header.tpl

您只需调整此页面上的菜单(静态更改)即可。要为您和您的员工等实际创建模块,然后按照本页面上发布的MVC教程进行操作:

How to create a custom Admin Page in Opencart?

答案 1 :(得分:2)

我已经在我的opencart项目中实现了你的概念。

注意:

1)默认情况下,在产品添加仪表板页面中有一个字段,用于输入您填写产品位置的产品位置并按照我的要点

2)打开目录> &model; category.php添加此代码

function getCategoryLoction($category_id) {
    $sql = "select p.location,count(p.location) as locCount from " . DB_PREFIX . "product p inner join " . DB_PREFIX . "product_to_category p2c on(p.product_id=p2c.product_id) where p2c.category_id=$category_id group by p.location";
    $query = $this->db->query($sql);
    return $query->rows;
}

3)打开目录>控制器>模块> category.php添加此代码

/* location based search starts here */
$incomingCatId  = ($this->data['category_id']!= '')?$this->data['category_id']:'0';
$locations  =   $this->model_catalog_category->getCategoryLoction($incomingCatId); 

foreach($locations as $loc):
    $this->data['locations'][] = array(
        'location' => $loc['location'],
        'count' =>  $loc['locCount'],
        'href' => $this->url->link('product/category', 'path=' . $incomingCatId.'&loc='.$loc['location'].'')
);
endforeach;    
/* location based search ends here */

4)打开目录> view> theme> default> template> module> category.tpl类别添加此代码

<div class="l_nav_box">
    <div class="l_nav_title">
        <h6>Location</h6>
    </div>
    <ul class="cat_ul">
         <?php if(!empty($locations)): ?>
         <?php foreach ($locations as $loc) : ?>
         <?php if($loc['location']!= ''): ?>
         <li> <a href="<?php echo $loc['href']; ?>"><?php echo $loc['location']; ?> <span>(<?php echo $loc['count']; ?>)</span> </a> </li>

         <?php endif; ?>
         <?php endforeach; ?>
         <?php else: ?>
         No Locations mentioned
         <?php endif; ?>    
    </ul>       
</div>

5)在管理员侧激活类别模块中重要并保存选择

相关问题