Post by elsnare » Mon Sep 09, 2013 11:24 pm

Hello guys!
What do I need
I need to hide some specific/individual products form the category product list.
The Idea
Using product "sort oder" field to input a negative value "-1", the product should not be displayed then.

I found a similar problem and topic here

OC 1.5.5.1
Thanks in advance! :)

Newbie

Posts

Joined
Mon Sep 09, 2013 11:02 pm

Post by grgr » Tue Sep 10, 2013 3:56 am

An even easier way is to edit the product and remove it from all the categories on the 'Links' tab.

Image Image Image Image Image Image Image Image


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by elsnare » Tue Sep 10, 2013 4:45 am

Thanks grgr, I have not thought of that :)
But I still need to have the product associated with the category. The product itself will be active and accessible, only by other - custom means that I have setup.

Your solution will be my backup plan if this can't be figured out.

Newbie

Posts

Joined
Mon Sep 09, 2013 11:02 pm

Post by PassionFlower » Tue Sep 10, 2013 9:44 am

To get the solution you described. Either edit the system files or make a vqmod.

in catalog/controller/product/category.php

After this line

Code: Select all

$this->data['products'][] = array(
Add this

Code: Select all

'sort_order' => $result['sort_order'];
And in catalog/view/theme/themename/template/product/category.tpl

After this line

Code: Select all

<?php foreach ($products as $product) { ?>
Add this

Code: Select all

<?php if($product['sort_order'] < 0) continue; ?>
Haven't tried it, but it shouldn't be more difficult than that.

You could also hard code the product id into the template, but it becomes less flexible and since this solution is so easy to do it's probably the best.

Newbie

Posts

Joined
Sat Aug 31, 2013 10:49 am

Post by elsnare » Thu Sep 12, 2013 9:17 pm

Works, now I can hide products like a boss :)
Thank you for your support.

Newbie

Posts

Joined
Mon Sep 09, 2013 11:02 pm

Post by IP_CAM » Fri Sep 01, 2017 12:38 pm

TESTED ON OC v.1.5.6.5 with Merkent responsive Bootstrap-3 Theme
---
controller/common/header.tpl

Code: Select all

line 107:	foreach ($categories as $category) {
line 108 ADD:	if ($category['sort_order'] == -1) { continue; }
line 109:	if ($category['top']) {
---
model/catalog/category.tpl
REPLACE at the end of this long line, this END Part:

Code: Select all

AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "'  AND c.status = '1' ORDER BY c.sort_order, LCASE(cd.name)");
with this End Part: (~Line 10)

Code: Select all

AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "'  AND c.sort_order <> '-1' ORDER BY c.sort_order, LCASE(cd.name)");
---
controller/module/category.php

Code: Select all

Line 34:	foreach ($categories as $category) {
Line 35 ADD:	if ($category['sort_order'] == -1) { continue; }
---
to finally get, what you see on the image below!
Thank you Guys! :D
Ernie
---
Image

Attachments

hide_categories_from_view.jpg

hide_categories_from_view.jpg (284.63 KiB) Viewed 1590 times


I'm rarely active at the OC Forum lately. To reach me, contact: jti@jacob.ch
A Demoversion of my free OpenCart LIGHT v.1.5.6.5 Software Edition
can be seen in real Action here: http://www.jti.li/shop/
---
1'300+ FREE OC Extension-Repositories - from OC v.1.5.x up,
on the world's largest OC-related Github Site: https://github.com/IP-CAM
---
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland
Who is online

Users browsing this forum: No registered users and 43 guests