Jump to content

[Solved] Modify statsproduct module to display Quantity Sold


Rhapsody

Recommended Posts

The BO tab for stats calls a module that displays product stats. The "Products Available" display includes a table that displays the following fields: Ref., Name, Stock

 

I would like to add a field that displays the number of items sold in addition to the stock.

 

It appears that the code for this is in the statsproduct.php file in the statsproduct module as pasted below. How would I modify the code to display the total number of items sold next to the number displayed for stock?

 

	<tr>
 <th>'.$this->l('Ref.').'</th>
 <th>'.$this->l('Name').'</th>
 <th>'.$this->l('Stock').'</th>
</tr>
  </thead><tbody>';
  foreach ($this->getProducts($cookie->id_lang) AS $product)
$this->_html .= '<tr><td>'.$product['reference'].'</td><td><a href="'.$currentIndex.'&token='.Tools::safeOutput(Tools::getValue('token')).'&module='.$this->name.'&id_product='.$product['id_product'].'">'.$product['name'].'</a></td><td>'.$product['quantity'].'</td></tr>';

 

Edit: Thanks to Bellini the request is solved. See his post below.

Link to comment
Share on other sites

  • 1 month later...

It has been a while since I've checked on this. Bump to see if anyone has an idea how the total sold can be displayed. I sell registrations for club membership and admission to club events so the inventory tracking is not used. I just need to tally the total sold.

Link to comment
Share on other sites

i think this should do it



   	 <thead>
			<tr>
				<th>'.$this->l('Ref.').'</th>
				<th>'.$this->l('Name').'</th>
				<th>'.$this->l('Stock').'</th>
				<th>'.$this->l('Sold').'</th>
			</tr>
		</thead><tbody>';
		foreach ($this->getProducts($cookie->id_lang) AS $product)
			$this->_html .= '<tr><td>'.$product['reference'].'</td><td><a href="'.$currentIndex.'&token='.Tools::safeOutput(Tools::getValue('token')).'&module='.$this->name.'&id_product='.$product['id_product'].'">'.$product['name'].'</a></td><td>'.$product['quantity'].'</td><td>'.$this->getTotalBought($product['id_product']).'</td></tr>';

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...