Post by ha33y » Mon Oct 11, 2010 5:06 am

My client has asked me to display in the home featured section all his lowest priced products. It suddenly occurred to me that when going into the products page in the admin there is no column for prices, infact there is no section in the admin that i can look at all the products and see their prices. I will have to go into each individual product one by one to see their price and then insert into the features section, that will take a long time for the complete product range. Is there a way to insert an extra column in the products adin page that will show all the prices and then can filter them by lowest/highest, I can then easily add them accordingly to the features section?

Thanks in advance

New member

Posts

Joined
Fri Sep 24, 2010 8:03 pm

Post by LeorLindel » Wed Nov 03, 2010 11:26 pm

Here how to add the price in the file admin/view/template/product/product_list.tpl

This modification also makes it possible to sort or filtrer products by price.

In admin/controller/catalog/product

Find (37):

Code: Select all

			if (isset($this->request->get['filter_quantity'])) {
				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
			}
After add:

Code: Select all

			if (isset($this->request->get['filter_price'])) {
				$url .= '&filter_price=' . $this->request->get['filter_price'];
			}

Find (85):

Code: Select all

			if (isset($this->request->get['filter_quantity'])) {
				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
			}
After add:

Code: Select all

			if (isset($this->request->get['filter_price'])) {
				$url .= '&filter_price=' . $this->request->get['filter_price'];
			}

Find (135):

Code: Select all

			if (isset($this->request->get['filter_quantity'])) {
				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
			}
After add:

Code: Select all

			if (isset($this->request->get['filter_price'])) {
				$url .= '&filter_price=' . $this->request->get['filter_price'];
			}

Find (185):

Code: Select all

			if (isset($this->request->get['filter_quantity'])) {
				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
			}
After add:

Code: Select all

			if (isset($this->request->get['filter_price'])) {
				$url .= '&filter_price=' . $this->request->get['filter_price'];
			}

Find (242):

Code: Select all

		if (isset($this->request->get['filter_quantity'])) {
			$filter_quantity = $this->request->get['filter_quantity'];
		} else {
			$filter_quantity = NULL;
		}
After add:

Code: Select all

		if (isset($this->request->get['filter_price'])) {
			$filter_price = $this->request->get['filter_price'];
		} else {
			$filter_price = NULL;
		}

Find (264):

Code: Select all

		if (isset($this->request->get['filter_quantity'])) {
			$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
		}
After add:

Code: Select all

		if (isset($this->request->get['filter_price'])) {
			$url .= '&filter_price=' . $this->request->get['filter_price'];
		}

Find (307):

Code: Select all

			'filter_quantity' => $filter_quantity,
After add:

Code: Select all

			'filter_price'      => $filter_price,
Find (340):

Code: Select all

				'quantity'   => $result['quantity'],
After add:

Code: Select all

				'price'	=> $result['price'],
Find (357):

Code: Select all

		$this->data['column_quantity'] = $this->language->get('column_quantity');
After add:

Code: Select all

		$this->data['column_price'] = $this->language->get('column_price');
Find (392):

Code: Select all

		if (isset($this->request->get['filter_quantity'])) {
			$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
		}
After add:

Code: Select all

		if (isset($this->request->get['filter_price'])) {
			$url .= '&filter_price=' . $this->request->get['filter_price'];
		}
Find (412):

Code: Select all

		$this->data['sort_quantity'] = HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . '&sort=p.quantity' . $url;
After add:

Code: Select all

		$this->data['sort_price'] = HTTPS_SERVER . 'index.php?route=catalog/product&token=' . $this->session->data['token'] . '&sort=p.price' . $url;
Find (426):

Code: Select all

		if (isset($this->request->get['filter_quantity'])) {
			$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
		}

After add:

Code: Select all

		if (isset($this->request->get['filter_price'])) {
			$url .= '&filter_price=' . $this->request->get['filter_price'];
		}

Find (453):

Code: Select all

		$this->data['filter_quantity'] = $filter_quantity;
After add:

Code: Select all

		$this->data['filter_price'] = $filter_price;
Find (588):

Code: Select all

		if (isset($this->request->get['filter_quantity'])) {
			$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
		}

After add:

Code: Select all

		if (isset($this->request->get['filter_price'])) {
			$url .= '&filter_price=' . $this->request->get['filter_price'];
		}

In admin/model/catalog/product.php

Find (287):

Code: Select all

			if (isset($data['filter_quantity']) && !is_null($data['filter_quantity'])) {
				$sql .= " AND p.quantity = '" . $this->db->escape($data['filter_quantity']) . "'";
			}

After add:

Code: Select all

			if (isset($data['filter_price']) && !is_null($data['filter_price'])) {
				$sql .= " AND p.price = '" . $this->db->escape($data['filter_price']) . "'";
			}

Find (298):

Code: Select all

				'p.quantity',
After add:

Code: Select all

				'p.price',
Find (543):

Code: Select all

		if (isset($data['filter_quantity']) && !is_null($data['filter_quantity'])) {
			$sql .= " AND p.quantity = '" . $this->db->escape($data['filter_quantity']) . "'";
		}

After add:

Code: Select all

		if (isset($data['filter_price']) && !is_null($data['filter_price'])) {
			$sql .= " AND p.price = '" . $this->db->escape($data['filter_price']) . "'";
		}
		
In admin/language/enclish/catalog/product.php

Find (22):

Code: Select all

$_['column_quantity']        = 'Quantity';
After add:

Code: Select all

$_['column_price']           = 'Price';
In admin/view/template/catalog/product_list.tpl

Find (32):

Code: Select all

			<td class="right"><?php if ($sort == 'p.quantity') { ?>
			  <a href="<?php echo $sort_quantity; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_quantity; ?></a>
			  <?php } else { ?>
			  <a href="<?php echo $sort_quantity; ?>"><?php echo $column_quantity; ?></a>
              <?php } ?></td>
After add:

Code: Select all

			<td class="right"><?php if ($sort == 'p.price') { ?>
			  <a href="<?php echo $sort_price; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_price; ?></a>
			  <?php } else { ?>
			  <a href="<?php echo $sort_price; ?>"><?php echo $column_price; ?></a>
              <?php } ?></td>
Find (51):

Code: Select all

            <td align="right"><input type="text" name="filter_quantity" value="<?php echo $filter_quantity; ?>" style="text-align: right;" /></td>
After add:

Code: Select all

            <td align="right"><input type="text" name="filter_price" value="<?php echo $filter_price; ?>" style="text-align: right;" /></td>
Find (78):

Code: Select all

            <td class="right"><?php if ($product['quantity'] <= 0) { ?>
              <span style="color: #FF0000;"><?php echo $product['quantity']; ?></span>
              <?php } elseif ($product['quantity'] <= 5) { ?>
              <span style="color: #FFA500;"><?php echo $product['quantity']; ?></span>
              <?php } else { ?>
              <span style="color: #008000;"><?php echo $product['quantity']; ?></span>
              <?php } ?></td>
After add:

Code: Select all

			<td class="right"><?php echo $product['price']; ?></td>
Find (118):

Code: Select all

	var filter_quantity = $('input[name=\'filter_quantity\']').attr('value');
	
	if (filter_quantity) {
		url += '&filter_quantity=' + encodeURIComponent(filter_quantity);
	}
	
After add:

Code: Select all

	var filter_price = $('input[name=\'filter_price\']').attr('value');
	
	if (filter_price) {
		url += '&filter_price=' + encodeURIComponent(filter_price);
	}
	
Last edited by LeorLindel on Sat Dec 18, 2010 5:52 pm, edited 1 time in total.

Tous les packs de langues Française depuis la v1.4.7 et toutes les versions intégrales 100 % Français sont disponibles sur le Portail Officiel Français.

Image


User avatar
Active Member

Posts

Joined
Mon Feb 22, 2010 8:05 pm

Post by (cj) » Sat Dec 18, 2010 6:45 am

Hey - thanks for this. I was also looking for a way to show all the prices and this does the trick. Except.....


********* Make note of this: *********

In admin/language/enclish/catalog/product.php

Find (22):
Code: Select all
$_['column_quantity'] = 'Quantity';
After add:
Code: Select all
$_['column_price] = 'Price';
***** Should be $_['column_price'] = 'Price';
***** The ending Apostrophe on 'column_price' is missing.

I edited it this on mine (after getting a syntax error) and now it works.

(cj)
http://www.adventhouseplans.com
----
Opencart v2.3.0.2 no VQMod yet


New member

Posts

Joined
Fri Dec 17, 2010 6:17 am

Post by Qphoria » Sat Dec 18, 2010 9:32 am

This was also added to the upcoming 1.4.9.3 btw

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by LeorLindel » Sat Dec 18, 2010 5:54 pm

(cj) wrote: In admin/language/enclish/catalog/product.php

Find (22):
Code: Select all
$_['column_quantity'] = 'Quantity';
After add:
Code: Select all
$_['column_price] = 'Price';
***** Should be $_['column_price'] = 'Price';
***** The ending Apostrophe on 'column_price' is missing.

I edited it this on mine (after getting a syntax error) and now it works.
I fixed the above topic

Thanks

Tous les packs de langues Française depuis la v1.4.7 et toutes les versions intégrales 100 % Français sont disponibles sur le Portail Officiel Français.

Image


User avatar
Active Member

Posts

Joined
Mon Feb 22, 2010 8:05 pm
Who is online

Users browsing this forum: No registered users and 17 guests