How to add new module to opencart administration?

后端 未结 2 1234
南笙
南笙 2021-02-06 15:01

I want to add a sub menu item \"Locations\" to \"Catalog\" menu item in opencart administration. On selecting locations, I want to see my own location management view page which

2条回答
  •  抹茶落季
    2021-02-06 15:46

    I have already implemented your concept in my opencart project.

    Notes:

    1) by default in product adding dashboard page have a field to enter product location you fill product location there and follow my points

    2) open catalog > model > category.php add this code

    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) open catalog > controller>module > category.php add this code

    /* 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) open catalog > view >theme >default >template>module > category.tpl category add this code

    
    

    5) important in admin side activate category module and save it choose

提交回复
热议问题