Post by Alsaru » Mon Apr 22, 2013 7:25 pm

Hello,

I have to make a little trick and not display all the products in the category page.
For example I have 20 products in one category (which is the parent category and have no children).
But, when I call the category page in the front store I want to display only a few products (based on some variables I might set later).
Here is what I have tried until now:

In catalog/view/template/product/category.tpl

Code: Select all

<div class="product-list">
    <?php foreach ($products as $product) { ?>
	 <?php if ($product['product_id'] == '50') { ?> // I have added this line. Also I have closed the If, later, right after the foreach end.
    <div>
Having this line, now, the category page hide all the divs for the products that are not with the Id 50, but somehow, the pagination is still visible and my product with the Id 50 is placed at the third page, even if page 1 and page 2 are empty and wouldn't suppose to appear.

I have also tried to filter the php in the controller but still no luck, or maybe I didn't know where to If them.

Any help appreciated

Thanks for reading

New member

Posts

Joined
Wed Feb 29, 2012 1:33 am

Post by rempong » Mon Apr 22, 2013 9:41 pm

Maybe you can try direct limiting on model.

OPENCART MODULE :
Opencart Compare Link VQMOD, Link your compared product to forum/email

Copy and DIRECTLY Edit Product, the easy way.

Custom Product Sort, Full control to product sorting options

Already Sold Product Module, shows total product sold

Opencart Shortcode (Wordpress Clone)


Active Member

Posts

Joined
Fri Sep 14, 2012 2:38 pm
Location - Indonesia

Post by rwenve » Fri May 24, 2013 12:01 am

I have run into this scenario as well. I have filtered the products out and I have counted how many have been excluded but I cant figure out how to pass that variable into the controller (where pagination is rendered?) so that it passes on to pagination.php - is there a way to call the Pagination() from the category.tpl and skip all that? or has someone figured something else out?

Thanks

Newbie

Posts

Joined
Wed Feb 08, 2012 5:40 am

Post by jgsw » Fri May 24, 2013 12:34 am

Hi Alsaru

You need to look in the catalog/controller/product/category.php

Try changing

Code: Select all

foreach ($results as $result) {
to

Code: Select all

$product_total=0;
foreach ($results as $result) {
    if ($result['product_id'] == 30) {
        $product_total++;
...

Code: Select all

    }
dont forget to close the '}'

jgsw

Quick Edit Admin Panel (40% off!) - CSS Unique (only $10!)
Sticky Admin Menu (Free) - Add Scripts & Styles to head (Free)


Active Member

Posts

Joined
Sat Mar 16, 2013 3:13 am
Who is online

Users browsing this forum: Bing [Bot] and 38 guests