The following Yii components are pre-configured to work in your OpenCart:


Rendering the default Yii SiteController - index.php?route=site/index
Rendering the default admin Yii SiteController - admin/index.php?route=site/index
Using Gii to build all models - admin/index.php?route=gii/prefixModel/index
An error with YII_DEBUG set to true
An error with YII_DEBUG set to false


Download the latest release or development version and uncompress the upload folder into your opencart installation.


The application has been tested with the following software versions, however should work with any minor revision change:

Copy the Yii config files in catalog/yiiembed/config/main-dist.php and admin/yiiembed/config/main-dist.php to main.php.

vQmod Installation

If you have installed vQmod then no further installation is required.

Manual Installation


BEFORE the closing php tag ?>

require_once(DIR_SYSTEM . 'yiiembed/yiiembed.php');


AFTER $this->registry = $registry;

Yii::createApplication('OcWebApplication', array('registry' => $registry, 'front' => $this));


BEFORE echo $output;


catalog/controller/error/not_found.php and admin/controller/error/not_found.php

AFTER public function index() {



AFTER $this->data['permissions'] = array();

$this->data['permissions'] = array_merge($this->data['permissions'], Yii::app()->getPermissionList());


BEFORE return in_array($value, $this->permission[$key]);

if (in_array(implode('/', array_slice(explode('/', $value), 0, 1)), $this->permission[$key])) return true;


Edit the Yii config files in catalog/yiiembed/config/main.php and admin/yiiembed/config/main.php (you should have copied these from main-dist.php during the installation).

Add Yii constants to your OpenCart config.php, defaults shown below:

define('YII_DEBUG', false); // set to true for fancy error messages
define('YII_TRACE_LEVEL', 0);

Navigate to Admin > System > Users > User Groups, then edit the Top Administrator. Select all the permissions for all the Yii pages. Repeat for any other User Groups that need to access these pages.

Extending and Upgrading

The files in catalog/yiiembed and admin/yiiembed are intended to be modified by you. When upgrading please ensure you do not overwrite your modified yiiembed applications with the default applications.

The files in system/yiiembed are intended to be in-sync with this project. Please avoid changing them, you can extend them if you require modifications.

Common Issues

JavaScript not working

It is probably because your JavaScript from Yii is outputting too early. The <title> tag is too high on the page. Yii outputs all the CSS/JS right before the <title> tag, so try moving it below your other CSS/JS files.

enableClientValidation not working in catalog when using chrome

jQuery in chrome treats inline elements as hidden. In the default opencart stylesheet on line 46, there is CSS to make forms display inline. You can remove this, or add 'htmlOptions' => array('style'=>'display:block;') to your form.

Model name conflicts

If you get an error like Customer::__construct() Missing argument 1 for Customer::__construct(), it is because there is already a Customer class built into OpenCart. You should name your models with a prefix, for example OcCustomer.



Find and save a record (in this example we use a Customer):

$customer_id = 123;
$customer = OcCustomer::model()->findByPk($customer_id);
if ($customer) {
    $customer->firstname = 'Foo';
    $customer->lastname = 'Bar';

Render Yii partial views:


Render Yii widgets:

Yii::app()->controller->widget('zii.widgets.CDetailView', array(
    'data' => array('hello' => 'world'),

Run OpenCart controller:


Get OpenCart controller output:

echo Yii::app()->getOcControllerOutput('common/header');
echo 'hello world';
echo Yii::app()->getOcControllerOutput('common/footer');

Output OpenCart language label:

Yii::t('module/bestseller', 'heading_title');

Gii Code Generator

You can use Yii's awesome code generator from your OpenCart admin, just like you can in any other Yii app. Simply browse to your admin admin/index.php?route=gii.

To tune the Gii configuration or security access edit admin/yiiembed/config/main.php.

PrefixModel Generator

Use the PrefixModel Generator to generate all your models in one action.

Select the Code Template yiiembed to generate models the same as ours.

ModelDoc Generator

Use the ModelDoc Generator to replace the phpdoc blocks in your models.

Other Generators

All the default Gii Generators including Controller Generator, Crud Generator, Form Generator, Model Generator and Module Generator are also available.