Find
Code: Select all
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'pd.name';
}
Code: Select all
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'p.date_added'; //Can also do by p.date_modified
}
Code: Select all
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
Code: Select all
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'DESC';
}
Code: Select all
$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')
);
Code: Select all
$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')
);
Add
Code: Select all
$_['text_date_desc']= 'Newest > Oldest';
$_['text_date_asc'] = 'Oldest > Newest';
Find
Code: Select all
$sort_data = array(
Code: Select all
'p.date_added'
Edit: Forgot about model
catalog/controller/product/category.php (original 1.4.8b codes).
Code: Select all
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'p.sort_order';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
this is the example http://www.sanfashions.com
Code: Select all
<?php
class ControllerProductCategory extends Controller {
public function index() {
$this->language->load('product/category');
$this->document->breadcrumbs = array();
$this->document->breadcrumbs[] = array(
'href' => HTTP_SERVER . 'index.php?route=common/home',
'text' => $this->language->get('text_home'),
'separator' => FALSE
);
$this->load->model('catalog/category');
$this->load->model('tool/seo_url');
if (isset($this->request->get['path'])) {
$path = '';
$parts = explode('_', $this->request->get['path']);
foreach ($parts as $path_id) {
$category_info = $this->model_catalog_category->getCategory($path_id);
if ($category_info) {
if (!$path) {
$path = $path_id;
} else {
$path .= '_' . $path_id;
}
$this->document->breadcrumbs[] = array(
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $path),
'text' => $category_info['name'],
'separator' => $this->language->get('text_separator')
);
}
}
$category_id = array_pop($parts);
} else {
$category_id = 0;
}
$category_info = $this->model_catalog_category->getCategory($category_id);
if ($category_info) {
$this->document->title = $category_info['name'];
$this->document->keywords = $category_info['meta_keywords'];
$this->document->description = $category_info['meta_description'];
$this->data['heading_title'] = $category_info['name'];
$this->data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8');
$this->data['text_sort'] = $this->language->get('text_sort');
$this->load->model('tool/image');
if ($category_info['image']) {
$image = $category_info['image'];
} else {
$image = '';
}
$this->data['thumb'] = $this->model_tool_image->resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'));
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'p.sort_order';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
$this->load->model('catalog/product');
$category_total = $this->model_catalog_category->getTotalCategoriesByCategoryId($category_id);
$product_total = $this->model_catalog_product->getTotalProductsByCategoryId($category_id);
if ($category_total || $product_total) {
$this->data['categories'] = array();
$results = $this->model_catalog_category->getCategories($category_id);
foreach ($results as $result) {
if ($result['image']) {
$image = $result['image'];
} else {
$image = 'no_image.jpg';
}
$this->data['categories'][] = array(
'name' => $result['name'],
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url),
'thumb' => $this->model_tool_image->resize($image, $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'))
);
}
$this->load->model('catalog/review');
$this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart');
$this->data['products'] = array();
$results = $this->model_catalog_product->getProductsByCategoryId($category_id, $sort, $order, ($page - 1) * $this->config->get('config_catalog_limit'), $this->config->get('config_catalog_limit'));
foreach ($results as $result) {
if ($result['image']) {
$image = $result['image'];
} else {
$image = 'no_image.jpg';
}
if ($this->config->get('config_review')) {
$rating = $this->model_catalog_review->getAverageRating($result['product_id']);
} else {
$rating = false;
}
$special = FALSE;
$discount = $this->model_catalog_product->getProductDiscount($result['product_id']);
if ($discount) {
$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($result['product_id']);
if ($special) {
$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
}
}
$options = $this->model_catalog_product->getProductOptions($result['product_id']);
if ($options) {
$add = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id']);
} else {
$add = HTTPS_SERVER . 'index.php?route=checkout/cart&product_id=' . $result['product_id'];
}
$this->data['products'][] = array(
'name' => $result['name'],
'model' => $result['model'],
'rating' => $rating,
'stars' => sprintf($this->language->get('text_stars'), $rating),
'thumb' => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
'price' => $price,
'options' => $options,
'special' => $special,
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&path=' . $this->request->get['path'] . '&product_id=' . $result['product_id']),
'add' => $add
);
}
if (!$this->config->get('config_customer_price')) {
$this->data['display_price'] = TRUE;
} elseif ($this->customer->isLogged()) {
$this->data['display_price'] = TRUE;
} else {
$this->data['display_price'] = FALSE;
}
$url = '';
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->data['sorts'] = array();
$this->data['sorts'][] = array(
'text' => $this->language->get('text_default'),
'value' => 'p.sort_order-ASC',
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=p.sort_order&order=ASC')
);
$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')
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_name_desc'),
'value' => 'pd.name-DESC',
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=pd.name&order=DESC')
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_price_asc'),
'value' => 'p.price-ASC',
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=p.price&order=ASC')
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_price_desc'),
'value' => 'p.price-DESC',
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=p.price&order=DESC')
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_rating_desc'),
'value' => 'rating-DESC',
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=rating&order=DESC')
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_rating_asc'),
'value' => 'rating-ASC',
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=rating&order=ASC')
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_model_asc'),
'value' => 'p.model-ASC',
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=p.model&order=ASC')
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_model_desc'),
'value' => 'p.model-DESC',
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . '&sort=p.model&order=DESC')
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
$pagination = new Pagination();
$pagination->total = $product_total;
$pagination->page = $page;
$pagination->limit = $this->config->get('config_catalog_limit');
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . $url . '&page={page}');
$this->data['pagination'] = $pagination->render();
$this->data['sort'] = $sort;
$this->data['order'] = $order;
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/category.tpl';
} else {
$this->template = 'default/template/product/category.tpl';
}
$this->children = array(
'common/column_right',
'common/column_left',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
} else {
$this->document->title = $category_info['name'];
$this->document->description = $category_info['meta_description'];
$this->data['heading_title'] = $category_info['name'];
$this->data['text_error'] = $this->language->get('text_empty');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['continue'] = HTTP_SERVER . 'index.php?route=common/home';
$this->data['categories'] = array();
$this->data['products'] = array();
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/category.tpl';
} else {
$this->template = 'default/template/product/category.tpl';
}
$this->children = array(
'common/column_right',
'common/column_left',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
}
} else {
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
if (isset($this->request->get['path'])) {
$this->document->breadcrumbs[] = array(
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $this->request->get['path'] . $url),
'text' => $this->language->get('text_error'),
'separator' => $this->language->get('text_separator')
);
}
$this->document->title = $this->language->get('text_error');
$this->data['heading_title'] = $this->language->get('text_error');
$this->data['text_error'] = $this->language->get('text_error');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['continue'] = HTTP_SERVER . 'index.php?route=common/home';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
} else {
$this->template = 'default/template/error/not_found.tpl';
}
$this->children = array(
'common/column_right',
'common/column_left',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
}
}
}
?>
I don't know much about PHP...~~
Don't know much about JQuery...~~
But I do know that I love OC!~~
and I know that if you'd guide me, what a wonderful world this would be...!~~
_________________________________________________________________
Using OC 1.4.9.2
http://www.ten2hundred.com
I don't know much about PHP...~~
Don't know much about JQuery...~~
But I do know that I love OC!~~
and I know that if you'd guide me, what a wonderful world this would be...!~~
_________________________________________________________________
Using OC 1.4.9.2
http://www.ten2hundred.com
!if you dont know what re you doing please find anyone have programing background or you'll messing up your site.
Attachments
Try with you own risk
Your code is wrong.Maio wrote:
You can download the attachment then extract it to the catalog it will rewrite your 3 categories.php then you're done. i made it from OC 1.4.9.3, it should be work on any 1.4.9.x because nothing have been change.
kaos jersey, jersey bola, baju bola, baju bola terbaru, baju bola murah
Attachments
Code: Select all
'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')
Code: Select all
'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')
Code: Select all
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=DESC' . $url)
Code: Select all
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=ASC' . $url)
Yes, this is worked on .1.5.4These should be altered to be like this:
CODE: SELECT ALL
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=DESC' . $url)
and
CODE: SELECT ALL
'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=p.date_added&order=ASC' . $url)
This worked for me anyway :-)
this is what I need! Thankyou Very much! This is worked on OC 1.5.4ncc50446@hotmail.com wrote:Go to catalog/controller/product/category.php
FindChange toCode: Select all
if (isset($this->request->get['sort'])) { $sort = $this->request->get['sort']; } else { $sort = 'pd.name'; }
FindCode: Select all
if (isset($this->request->get['sort'])) { $sort = $this->request->get['sort']; } else { $sort = 'p.date_added'; //Can also do by p.date_modified }
Change toCode: Select all
if (isset($this->request->get['order'])) { $order = $this->request->get['order']; } else { $order = 'ASC'; }
FindCode: Select all
if (isset($this->request->get['order'])) { $order = $this->request->get['order']; } else { $order = 'DESC'; }
Add beforeCode: Select all
$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') );
Go to catalog/language/english/product/category.phpCode: Select all
$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') );
AddGo to catalog/model/catalog/product.phpCode: Select all
$_['text_date_desc']= 'Newest > Oldest'; $_['text_date_asc'] = 'Oldest > Newest';
FindAdd into the array, at the endCode: Select all
$sort_data = array(
I think that's all of itCode: Select all
'p.date_added'
Edit: Forgot about model
this is the example http://www.chantiqbutik.com
BUT there's a problem, whenever I am on the category page, I have a message at the top most part of the page which says below:
application/x-httpd-php category.php ( PHP script text )
And I get 2 scroll bars at the right side of the window, as if there are two windows one over another.
Now, I do not know what went wrong, if it did.
Sorting thing is working perfectly fine though!
Any help will be highly appreciated.
Eagerly awaiting your response.
Thanks!
Users browsing this forum: No registered users and 92 guests