Viewed   133 times

I want to know how to make a custom admin panel page in opencart.

Requires login with the controller - the admin panel does not seem to use the same controller as the normal site. I know how to make custom pages with opencart (but this is not for the admin)

A simple Hello World example would be great



OpenCart 2.x

The path names have changed in OpenCart 2 - you will want to create

admin/controller/extension/module/hello.php admin/language/en-gb/extension/module/hello.php admin/view/template/extension/module/hello.tpl Then the route becomes


OpenCart 1.x

  • Include full MVC flow.

I found out how to do this. OpenCart uses the MVC pattern. I recommend reading about How to be an OpenCart Guru? post about learning how the system works - this Admin workflow should also suffice for customer end.

1) Create a new file in admin/controller/custom/helloworld.php

Your filename and controller name should be the same in desc order:



class ControllerCustomHelloWorld extends Controller{ 
    public function index(){
                // VARS
                $template="custom/hello.tpl"; // .tpl location and file
        $this->template = ''.$template.'';
        $this->children = array(

2) Create a new file in admin/view/template/custom/hello.tpl


<?php echo $header; ?>
<div id="content">
echo 'I can also run PHP too!'; 
<?php echo $footer; ?>

3) Create a new file in admin/model/custom/hello.php

class ModelCustomHello extends Model {
    public function HellWorld() {
        $sql = "SELECT x FROM `" . DB_PREFIX . "y`)"; 
        $implode = array();
        $query = $this->db->query($sql);
        return $query->row['total'];    

4) You then need to enable the plugin to avoid permission denied errors:

Opencart > Admin > Users > User Groups > Admin > Edit

Select and Enable the Access Permission.

To visit your page go to

Tuesday, November 8, 2022

I'm firmly in the 1 camp. Currency conversion is core business logic, and belongs in your models, not your views.

Further, although money looks like floating-point numbers, it isn't. Money changes hands in integer quantities of whatever your base unit is. In the US, for example, If gumballs are 10 cents each and I buy ten, then I'm trading 100 pennies for 10 gumballs. Even if I give a dollar bill, from a software perspective, it's best to count that as 100 pennies.

For more on this, see Martin Fowler's "Patterns of Enterprise Application Architecture" and "Analysis Patterns". He talks through all the issues in detail and gives good sample code. You can also find some of that info on the web:

  • Quantity (with some money sample code)
  • Money (mainly a pointer into his book)

If you need the accounting to work, I'd also talk to the accountant. Currency conversion is often complicated by changing rates, weird fees, and other nonsense, and you can spend a long time chasing pennies to make the books balance if you don't get it right from the get-go.

Monday, August 8, 2022

If You really need to have the multi-domain multi-store, You can achieve it by setting up the sub-domain multi-store first and then making the domains to be aliases to this sub-domains, e.g.

  • Default Store ->
  • Store 1 ->
  • Store 2 ->
  • Store 3 ->

and then

  • ->
  • ->
  • ->

Though the Store 1 could be accessed now by both and it is up to marketing to deliver only URL. Perhaps some other .htaccess restrictions/redirect from direct access to may be set but this is not necessary at all. Using these aliases to sub-domains You should be able to preserve all the functionality of multi-store on sub-domains...

Sunday, December 11, 2022

hmmm. Thanks for your help everyone. The solution I have come up ( with your help ofcourse :) is as follows:

I have two custom templates:



class MyModel(object):
    # ... Access other models
    # ... process / normalise data 
    # ... store data

def my_model_list_view(request) #show list of all objects
    #. . . create objects of MyModel . . .
    #. . . call their processing methods . . .
    #. . . store in context variable . . . 
    r = render_to_response('admin/myapp/my_model_list.html', context, RequestContext(request))
    return HttpResponse(r)

def my_model_detail_view(request, row_id) # Shows one row (all values in the object) in detail     
    #. . . create object of MyModel . . .
    #. . . call it's methods . . .
    #. . . store in context variable . . . 
    r = render_to_response('admin/myapp/my_model_detail.html', context, RequestContext(request))
    return HttpResponse(r)

Under the main django

urlpatterns = patterns( 
    (r'^admin/myapp/mymodel/$', my_model_list_view),
    (r'^admin/myapp/mymodel/(d+)/$', my_model_detail_view),
    ( r'^admin/', include( ) )
Sunday, September 25, 2022

You would want to update the api.error content definition:

<!-- This content definition is to render an error page that displays unhandled errors. -->
<ContentDefinition Id="api.error">
    <Item Key="DisplayName">Error page</Item>
Tuesday, November 15, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :