Post by adensoft » Sun Oct 28, 2018 3:03 am

can any one help me?
Is there a way to sort the invoice on product model(A-Z)?

Newbie

Posts

Joined
Sun May 28, 2017 7:08 pm

Post by straightlight » Sun Oct 28, 2018 4:24 am

Tested on v3.0.2.0 release.

In admin/model/sale/order.php file, in the getOrders($data = array()) method,

replace:

Code: Select all

$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
with:

Code: Select all

$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o INNER JOIN `" . DB_PREFIX . "order_product` `op` ON (`op`.`order_id` = `o`.`order_id`)";
Then, on the same method,

find:

Code: Select all

if (!empty($data['filter_total'])) {
			$sql .= " AND o.total = '" . (float)$data['filter_total'] . "'";
		}
add below:

Code: Select all

if (!empty($data['filter_model'])) {
    $sql .= " AND `op`.`model` = '" . $this->db->escape($data['filter_model']) . "'";
}
Then, right below,

find:

Code: Select all

'o.date_modified',
add afterwards:

Code: Select all

'op.model',
In admin/controller/sale/order.php file,

find all instances of:

Code: Select all

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

Code: Select all

if (isset($this->request->get['filter_model'])) {
   $url .= "&filter_model=' . $this->request->get['filter_model'];
}
Then, find:

Code: Select all

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

Code: Select all

if (isset($this->request->get['filter_model'])) {
			$filter_model = $this->request->get['filter_model'];
		} else {
			$filter_model = '';
		}	
Then, find:

Code: Select all

'filter_total'           => $filter_total,
add below:

Code: Select all

'filter_model' => $filter_model,
Then, find:

Code: Select all

$data['sort_total'] = $this->url->link('sale/order', 'user_token=' . $this->session->data['user_token'] . '&sort=o.total' . $url);
add below:

Code: Select all

$data['sort_model'] = $this->url->link('sale/order', 'user_token=' . $this->session->data['user_token'] . '&sort=op.model' . $url);
Then, find:

Code: Select all

$data['filter_total'] = $filter_total;
add below:

Code: Select all

$data['filter_model'] = $filter_model;
In admin/language/en-gb/sale/order.php file,

add at the bottom:

Code: Select all

$_['column_model'] = 'Model';

$_['entry_model'] = 'Model';
Then, in admin/view/template/sale/order_list.twig file,

find:

Code: Select all

<td class="text-left">{% if sort == 'order_status' %} <a href="{{ sort_status }}" class="{{ order|lower }}">{{ column_status }}</a> {% else %} <a href="{{ sort_status }}">{{ column_status }}</a> {% endif %}</td>
add below:

Code: Select all

<td class="text-left">{% if sort == 'op.model' %} <a href="{{ sort_model }}" class="{{ order|lower }}">{{ column_model }}</a> {% else %} <a href="{{ sort_model }}">{{ column_model }}</a> {% endif %}</td>
Then, find:

Code: Select all

<div class="form-group">
              <label class="col-form-label" for="input-total">{{ entry_total }}</label> <input type="text" name="filter_total" value="{{ filter_total }}" placeholder="{{ entry_total }}" id="input-total" class="form-control"/>
            </div>
Add above (or below):

Code: Select all

<div class="form-group">
              <label class="col-form-label" for="input-model">{{ entry_model }}</label> <input type="text" name="filter_model" value="{{ filter_model }}" placeholder="{{ entry_model }}" id="input-model" class="form-control"/>
            </div>
Then, find:

Code: Select all

var filter_total = $('input[name=\'filter_total\']').val();

	if (filter_total) {
		url += '&filter_total=' + encodeURIComponent(filter_total);
	}
add below:

Code: Select all

var filter_model = $('input[name=\'filter_model\']').val();

	if (filter_model) {
		url += '&filter_model=' + encodeURIComponent(filter_model);
	}
This should provide what you need by filtering with product model after applying these FAQ steps: viewtopic.php?f=176&p=737014#p718325 .

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 17 guests