Post by harryo40 » Sun Aug 14, 2011 12:33 am

I am after showing the total quantity of items in admin?
When logged in to admin, it shows the total number products like this...
Showing 1 to 100 of 3463 (35 Pages) - at the bottom of the page & also in the admin>>dashboard, but I am after also seeing the total quantity of items for example, 1 product might have a quantity of 10 & another may have a quantity of 20 & so on.
Any help is appreciated ;)
Last edited by harryo40 on Wed Aug 17, 2011 1:48 am, edited 1 time in total.

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by harryo40 » Tue Aug 16, 2011 8:12 pm

I didnt think this would be to difficult to do but I have got a little further ;)
I have now managed to use the following SQL to show me the total quantity of item from within myphp

Code: Select all

SELECT SUM( quantity ) AS "Total Items" FROM product;
& this shows me the total items (not total products) as shown in the image below.
When I click create PHP code, it shows me

Code: Select all

$sql = "SELECT SUM( quantity ) AS \"Total Items\" FROM product";
& all i need to know now is, how to display this on the Dashboard of Admin, in the overview part ???

Attachments

OC1.png

What I am trying to show in Admin->Dashboard - OC1.png (10.26 KiB) Viewed 1419 times


Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by harryo40 » Wed Aug 17, 2011 1:48 am

Solved!
Added to model->product.php

Code: Select all

public function getTotalQuantity($data = array()) {
		$sql = "SELECT SUM( quantity ) AS total FROM product";

		$query = $this->db->query($sql);
		
		return $query->row['total'];
	}
& also added appropriate codes to home.php in Controller / Language / View

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by mkh » Fri Sep 02, 2011 8:00 am

Hmm, how do I get this to work ?

Really need the total product amount to show up on the admin front page ....

mkh
New member

Posts

Joined
Fri Jun 24, 2011 1:55 am

Post by harryo40 » Mon Sep 05, 2011 5:28 pm

mkh wrote:Hmm, how do I get this to work ?

Really need the total product amount to show up on the admin front page ....
What version of OC are you after this working in because I did this for 1.4.9.1

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by mkh » Tue Sep 06, 2011 1:25 am

What version of OC are you after this working in because I did this for 1.4.9.1
I'm using 1.5.1.1

mkh
New member

Posts

Joined
Fri Jun 24, 2011 1:55 am

Post by harryo40 » Wed Sep 07, 2011 1:15 am

mkh wrote:I'm using 1.5.1.1
Hi mkh,
Have you made any adjustments to the layout in admin?
I have just tried the same method on my demo page using 1.5.1.1 & it works fine.
You need to open & edit all the following files with the extra codes...
Open Admin->Controller->Common->home.php & Find...

Code: Select all

$this->data['total_order'] = $this->model_sale_order->getTotalOrders();
& after add (next line)...

Code: Select all

		$this->load->model('catalog/product');
		$this->data['total_quantity'] = $this->model_catalog_product->getTotalQuantity();
Then open Admin->Language->Common->home.php find...

Code: Select all

$_['text_total_order']              = 'Total Orders:';
& after add...

Code: Select all

$_['text_total_quantity']           = 'Total items:';
Then in Admin->Model->Catalog->Product.php find...

Code: Select all

	public function getTotalProductsByStockStatusId($stock_status_id) {
then BEFORE that line add...

Code: Select all

	public function getTotalQuantity($data = array()) {
		$sql = "SELECT SUM( quantity ) AS total FROM product";

		$query = $this->db->query($sql);
		
		return $query->row['total'];
	}
& finally open Admin->View->Template->Common->home.tpl & find...

Code: Select all

            <tr>
              <td><?php echo $text_total_order; ?></td>
              <td><?php echo $total_order; ?></td>
            </tr>
then after add...

Code: Select all

            <tr>
              <td><?php echo $text_total_quantity; ?></td>
              <td align="right"><?php echo $total_quantity; ?></td>
            </tr>
            <tr>
This will show an extra line called 'Total Items' in admin front page (Dashboard) & below Total Orders ;)
If you havn't made any changes to the Admin side of OC1.5.1.1 I can put this together so you would just need to upload the folder & it will install the code ;) otherwise, the above way is the manual way.

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by mkh » Wed Sep 07, 2011 1:35 am

harryo40 : Thank you SO much, I could not make the lang file work, so just added the title myself, but it works, thanks again...

/mkh

mkh
New member

Posts

Joined
Fri Jun 24, 2011 1:55 am

Post by harryo40 » Wed Sep 07, 2011 1:36 am

Glad to have helped ;)

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire

Post by mkh » Wed Sep 07, 2011 1:46 am

Okay, found a tiny bug, this should work perfect.

Code: Select all

	public function getTotalQuantity($data = array()) {
	      $query = $this->db->query("SELECT count(*) AS total FROM " . DB_PREFIX . "product");

	      return $query->row['total'];
	   }

mkh
New member

Posts

Joined
Fri Jun 24, 2011 1:55 am

Post by harryo40 » Wed Sep 07, 2011 1:54 am

Yep I forgot I only moved the coding over from 1.4.9.1 to 1.5.1.1 & without changing any of it, but at least it works & shows you what you wanted ;)

Add To Cart Confirm Ajax Popup for OC 1.5.1.3 --> 1.5.5.1 - Add to Cart Confirmation Popup
Image Map Banner Module - Image Map Banner Module
----------------------------------------------------------------------
Womens Famous Name Fashion Clothing at bargain prices - Next2nowt.com


Active Member

Posts

Joined
Wed Oct 21, 2009 3:37 am
Location - Blackburn, Lancashire
Who is online

Users browsing this forum: No registered users and 16 guests