Membuat Sort Newest to Oldest Di Open Cart

Pergi Ke catalog/controller/product/category.php

Cari Code:

if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'pd.name';
}

Ganti Ke:

if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'p.date_added'; //dapat juga dengan code p.date_modified
}

Cari Code:

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

Ganti Ke:

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

Cari Code:

$this->data['sorts'][] = array(
'text'  => $this->language->get('text_name_asc'),
'value' => 'pd.name-ASC',
'href'  => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=pd.name&order=ASC')
);

Tambahkan disebelum atau sesudah kode diatas (tergantung keinginan) code:

$this->data['sorts'][] = array(
'text'  => $this->language->get('text_date_desc'),
'value' => 'p.date_added-DESC',
'href'  => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=p.date_added&order=DESC')
);
$this->data['sorts'][] = array(
'text'  => $this->language->get('text_date_asc'),
'value' => 'p.date_added-ASC',
'href'  => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=p.date_added&order=ASC')
);

Pergi ke catalog/language/english/product/category.php
Tambahkan Code:

$_['text_date_desc']= 'Newest > Oldest';
$_['text_date_asc']    = 'Oldest > Newest';

Pergi ke catalog/model/catalog/product.php
Cari Code:

$sort_data = array(

Tambahkan kedalam array tersebut diakhirnya dengan Code:

'p.date_added'

Itulah semuanya

Teknody

Toko Komputer Batam yang menjual dan mendukung kebutuhan IT Anda sejak tahun 2011. Selalu berusaha untuk mengikuti perkembangan zaman, khususnya di bidang IT.

Tinggalkan Balasan

×
×

Cart