Post by riyarichards » Wed Jun 13, 2012 3:00 pm

Hi,

I want to display Product Viewed Report in Dashboard itself. Now the report id under Report->Products->Viewed

How to display it? I tried copying the code from admin->controller->report->product_viewed.php TO admin->controller->common->home.php

and copied the code from admin->view->report->product_viewed.tpl to admin->common->home.tpl

i have added code like this in home.tpl

Code: Select all

 <div class="content">
      <table class="list">
        <thead>
          <tr>
            <td class="left"><?php echo $column_name; ?></td>
            <td class="left"><?php echo $column_model; ?></td>
            <td class="right"><?php echo $column_viewed; ?></td>
            <td class="right"><?php echo $column_percent; ?></td>
          </tr>
        </thead>
        <tbody>
          <?php if ($products) { ?>
          <?php foreach ($products as $product) { ?>
          <tr>
            <td class="left"><?php echo $product['name']; ?></td>
            <td class="left"><?php echo $product['model']; ?></td>
            <td class="right"><?php echo $product['viewed']; ?></td>
            <td class="right"><?php echo $product['percent']; ?></td>
          </tr>
          <?php } ?>
          <?php } else { ?>
          <tr>
            <td class="center" colspan="4"><?php echo $text_no_results; ?></td>
          </tr>
          <?php } ?>
        </tbody>
      </table>
      </div>
in my admin panel-> dashboard i am getting error like this

Notice: Undefined variable: products in /Applications/MAMP/htdocs/opencart/admin/view/template/common/home.tpl on line 95Notice: Undefined variable: column_name in /Applications/MAMP/htdocs/opencart/admin/view/template/common/home.tpl on line 88 Notice: Undefined variable: column_model in /Applications/MAMP/htdocs/opencart/admin/view/template/common/home.tpl on line 89 Notice: Undefined variable: column_viewed in /Applications/MAMP/htdocs/opencart/admin/view/template/common/home.tpl on line 90 Notice: Undefined variable: column_percent in /Applications/MAMP/htdocs/opencart/admin/view/template/common/home.tpl on line 91


please help me in solving this? where i should declare this 'products' ?

Attachments

Screen shot 2012-06-13 at 12.29.48 PM.png

Screen shot 2012-06-13 at 12.29.48 PM.png (74.49 KiB) Viewed 1278 times


New member

Posts

Joined
Tue Jun 05, 2012 1:47 pm

Post by riyarichards » Wed Jun 13, 2012 5:47 pm

Somebody please help me in this :(

New member

Posts

Joined
Tue Jun 05, 2012 1:47 pm

Post by qahar » Wed Jun 13, 2012 5:59 pm

To solve the undefined products, what you need to copy from admin->controller->report->product_viewed.php is code bellow:

Code: Select all

$this->load->model('report/product');

$data = array(
	'start' => ($page - 1) * $this->config->get('config_admin_limit'),
	'limit' => $this->config->get('config_admin_limit')
);

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

$results = $this->model_report_product->getProductsViewed($data);
foreach ($results as $result) {
	if ($result['viewed']) {
		$percent = round($result['viewed'] / $product_views_total * 100, 2);
	} else {
		$percent = 0;
	}
	
	$this->data['products'][] = array(
		'name'    => $result['name'],
		'model'   => $result['model'],
		'viewed'  => $result['viewed'],
		'percent' => $percent . '%'			
	);
}

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by riyarichards » Wed Jun 13, 2012 11:19 pm

Thanks.

But please tell me where to paste this or where to use this code to display in dashboard?

New member

Posts

Joined
Tue Jun 05, 2012 1:47 pm

Post by riyarichards » Wed Jun 13, 2012 11:51 pm

Hey i got it!. Its displaying. But but only one line displaying in the top

Notice: Undefined variable page: page in home.php on line 133.

I am not getting why am getting this error. in home.php everything looks fine. please suggest me

New member

Posts

Joined
Tue Jun 05, 2012 1:47 pm

Post by qahar » Thu Jun 14, 2012 1:17 am

Not notice about $page on my code above. Just change:

Code: Select all

'start' => ($page - 1) * $this->config->get('config_admin_limit'),

to

'start' => 0,

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by silanli_53 » Mon Jan 07, 2013 12:48 am

qahar wrote:To solve the undefined products, what you need to copy from admin->controller->report->product_viewed.php is code bellow:

Code: Select all

$this->load->model('report/product');

$data = array(
	'start' => ($page - 1) * $this->config->get('config_admin_limit'),
	'limit' => $this->config->get('config_admin_limit')
);

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

$results = $this->model_report_product->getProductsViewed($data);
foreach ($results as $result) {
	if ($result['viewed']) {
		$percent = round($result['viewed'] / $product_views_total * 100, 2);
	} else {
		$percent = 0;
	}
	
	$this->data['products'][] = array(
		'name'    => $result['name'],
		'model'   => $result['model'],
		'viewed'  => $result['viewed'],
		'percent' => $percent . '%'			
	);
}

where you need to add code?

Cafe Koltuk Çeşitleri

Laptop Sırt Çantası


User avatar
New member

Posts

Joined
Fri Feb 19, 2010 8:54 am


Post by ChetanCx » Mon Jan 07, 2013 1:23 am

silanli_53 wrote:
where you need to add code?
paste this code in admin/controller/common/home.php inside public function index()

User avatar
Active Member

Posts

Joined
Sat Dec 08, 2012 8:12 pm
Who is online

Users browsing this forum: Amazon [Bot] and 289 guests