Forums / Templates, Stylesheets, Page Layout / Only display products with images.

Only display products with images.

Started by tantirx on 12 Apr 2011, 1:10 AM · Views: 1,110

Results 1 to 13 of 13
12 Apr 2011, 1:10 AM
#1
tantirx avatar

tantirx

New Zenner

Join Date:
Nov 2010
Posts:
52
Plugin Contributions:
0

Only display products with images.

is it possible to only display products on the main page that have a product image(s)?

EG...I have a few products with a "default" image that is used if no product image is available. I think the site looks tacky and unprofessional if there are a bunch of "default" images instead of only products with product images.

I am using v1.3.9h

Listing items of a category with no product imag is fine...I just don't want them showing up on the main page.

Any help would be awesome.

12 Apr 2011, 1:27 AM
#2
tantirx avatar

tantirx

New Zenner

Join Date:
Nov 2010
Posts:
52
Plugin Contributions:
0

Re: Only display products with images.

Is it possible to only display products on the main page that have a product image(s)?

EG...I have a few products with a "default" image that is used if no product image is available. I think the site looks tacky and unprofessional if there are a bunch of "default" images instead of only products with product images.

I am using v1.3.9h

Listing items of a category with no product imag is fine...I just don't want them showing up on the main page.

Any help would be awesome.

NOTE TO MODS
This is a double post please delete my original post from "Setting Up Categories, Products, Attributes"

12 Apr 2011, 2:17 AM
#3
tantirx avatar

tantirx

New Zenner

Join Date:
Nov 2010
Posts:
52
Plugin Contributions:
0

Re: Only display products with images.

I am 99% sure I will end up stumping almost everyone with this question. This is definitely a question for a programmer.

12 Apr 2011, 3:43 AM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Only display products with images.

In /includes/index_filters/default_filter.php, find the four statements beginning with

      $listing_sql = "select " . $select_column_list . "...

Add after the line

        where p.products_status = 1

a new line

          and p.products_image != ''

This will exclude products without assigned images from product listings. If you want to extend this functionality to other product types than product-general, edit the appropriate filter file.

12 Apr 2011, 3:50 AM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Only display products with images.

The above will affect all product listing pages. If you want to affect only the home page category listing (when you have a specific category open on the home page), it will need some tweaking. If you want to affect centerboxes rather than listings on the home page, a different filter would most likely need to be edited. Where exactly do you want this functionality?

12 Apr 2011, 4:26 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Only display products with images.

On these Products, is the products_image actually blank?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

13 Apr 2011, 1:11 AM
#7
tantirx avatar

tantirx

New Zenner

Join Date:
Nov 2010
Posts:
52
Plugin Contributions:
0

Re: Only display products with images.

Ajeh:

On these Products, is the products_image actually blank?

No ...I have a default image for products with no image(s) called no-image.gif. I will eventually be getting images for the products without them but in the interim would like to NOT have products with no image(s) be visible on the main page.

As you can see; the vast majority of the products with no images are specific species of fish....it is difficult to find good quality of images of these fish because some of them are rare or images are not available through the image sites I belong to eg: http://www.123rf.com/.

Check out the site at http://oceanabyssaquatics.ca/store/ :D

13 Apr 2011, 1:23 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Only display products with images.

If you have actually entered a specific image name in the products table for the field:
products_image

you could test for that and not show those products by customizing the SELECT statements in the files where you do not want these to show ...

If this is only on the main page, you can customize things further with the variable:
$this_is_home_page

which will be true when on the Home page ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

13 Apr 2011, 3:12 AM
#9
tantirx avatar

tantirx

New Zenner

Join Date:
Nov 2010
Posts:
52
Plugin Contributions:
0

Re: Only display products with images.

Ajeh:

If you have actually entered a specific image name in the products table for the field:
products_image

you could test for that and not show those products by customizing the SELECT statements in the files where you do not want these to show ...

If this is only on the main page, you can customize things further with the variable:
$this_is_home_page

which will be true when on the Home page ...

You kinda lost me...sorry. What I mean is...by default Zencart uses the no_picture.gif file for products with no image. I simply replaced that image with my own...you can see it below:

Now; I'm fluent in HTML and CSS... not so much in php. Therefore if you are going to make a programming suggestion kindly point me to the file to edit as well as the appropriate code and where to put it.

Thanks again for your patience with my ignorance.

13 Apr 2011, 3:55 AM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Only display products with images.

If you look at the table:
products

in your database ... on these Products with out images, are you saying the field:
products_image

is empty or does it contain your image for the no_picture.gif ...

So something like the module for the New Products, you can use your templates and overrides for:
/includes/modules/new_products.php

copying to your:
/includes/modules/your_template_dir/new_products.php

and add a condition to the SELECT statements ...

  $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                           where p.products_id = pd.products_id
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                           and p.products_image !=''
                           and   p.products_status = 1 " . $display_limit;

and the other SELECT statement:

    $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                                  p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                           where p.products_id = pd.products_id
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                           and p.products_status = 1
                           and p.products_image != ''
                           and p.products_id in (" . $list_of_products . ")";

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

13 Apr 2011, 6:01 AM
#12
tantirx avatar

tantirx

New Zenner

Join Date:
Nov 2010
Posts:
52
Plugin Contributions:
0

Re: Only display products with images.

Worked perfectly!!! You rock!! :jump:

13 Apr 2011, 12:55 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Only display products with images.

Thanks for the update that this works for you ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!