Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2007
    Posts
    15
    Plugin Contributions
    0

    Default If no image show no product

    I installed SQL patch that DrByte had in another post but it did not work.
    I have 1000s of products and alot have no image files, I would like these products not to show in the cart.
    At present the products wit no images show twice.
    1.37

    http://centurycomputeronline.com

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: If no image show no product

    You can look in your database in the products table to confirm this that the Products without an image have blank fields for the products_image ...

    If this is true ...

    Backup your database and you can run from your Zen Cart Admin in the Tools ... Insert SQL Patches ...

    PHP Code:
    UPDATE products SET products_status 0 WHERE products_image ''
    This will turn off ALL products from displaying in the Catalog where there is no image ...
    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: v1.5.5]
    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!

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: If no image show no product

    Wait stop ...

    These have images in the database table ... what you do not have are images on the server ...
    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: v1.5.5]
    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!

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: If no image show no product

    What you need is a script written for you that can check to see what images are missing from the server or ... customize the image code so when the image is not found but is stored in the database that it either displays nothing for the image or the missing image ...

    The double names is the in FireFox because of the image name and alt tag being displayed ...
    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: v1.5.5]
    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!

  5. #5
    Join Date
    Jan 2008
    Posts
    19
    Plugin Contributions
    0

    Default Re: If no image show no product

    I run this script via cron daily to test for images ( I have a system that updates product quantities and status from our brick-and-mortar POS system ). All of the YOUR_* info has to be replaced with your local info... I haven't been running this long, but it seems to do the job for me.

    This script looks at what active products have defined and tests if it is there. If it is not there, it ouputs "/YOUR_IMAGE_DIRECTORY/YOURIMAGE missing"

    If it finds the file, it tests for a specific issue I have with JPG's - it tries to "fix" the jpg and outputs what is what.


    PHP Code:
    session_start();

    $tim localtime(time(),true);
    echo 
    "product image check start..." .
         
    $tim['tm_hour'].":".$tim['tm_min'].":".$tim['tm_sec'] . "\n";

    $db mysql_connect("localhost""YOUR_DB_LOGINID""YOUR_DB_PASSWORD") or die("Could not connect.");

    if(!
    $db) die("no db");
    if(!
    mysql_select_db("YOUR_DB_NAME",$db)) die("No database selected.");

    // iterate through active products to find missing images.
    // z_ is my zen table prefix - it is required here.
    // only care about active products
    $result mysql_query" select products_image from z_products where products_status = 1 order by products_model") or die(mysql_error());

    while(
    $row mysql_fetch_array($result))
    {

       
    $image='YOUR_IMAGE_DIRECTORY' $row['products_image'];

       if ( !
    file_exists$image ) )
       {
          echo 
    $image " missing\n";
       }
       else
       {
          
    // test jpg's
          // I get some images from vendors that use 
          // 4 color channel jpg's (CMYK)
          // browsers can not display them correctly - or ih2
          
    $getimagesize getimagesize($image); 

          
    // test for bad jpg
          
    if ( isset($getimagesize['channels']) &&  
               
    $getimagesize['channels'] == &&  
               
    $getimagesize[2] == IMAGETYPE_JPEG )
          { 
             
    // try to convert the jpg to 3 color channel (RGB)
             
    $im = @imagecreatefromjpeg($image); 
             if (
    $im) {
           
    rename$image$image '.old' );
               
    imagejpeg($im$image100); 
               
    imagedestroy($im); 
               echo 
    $image " converted...\n";
         }
         else
         {
                echo 
    $image " bad jpg - cannot convert \n";
         }
          } 
       }
    }

    $tim localtime(time(),true);
    echo 
    "\nproduct image check finished..." .
    $tim['tm_hour'].":".$tim['tm_min'].":".$tim['tm_sec'] . "\n"

  6. #6
    Join Date
    Apr 2005
    Location
    Spokane, Washington
    Posts
    372
    Plugin Contributions
    0

    Default Re: If no image show no product

    Interesting bit of code. I am looking for something that will look at my catalog and tell me what products are are missing images.

    Will this do that?

    Just knowledgeable enough to be dangerous.

  7. #7
    Join Date
    Jan 2004
    Posts
    38
    Plugin Contributions
    0

    Default Re: If no image show no product

    I'm intrigued about your use of cron to run the script. Is that the entire PHP file or are there some lines at the top that you left off? Also, where does the output from your echo's go?

    I would like to do something similar using cron but don't have any experience invoking PHP with cron.

    Thanks ... Bowen

  8. #8
    Join Date
    Jan 2008
    Posts
    19
    Plugin Contributions
    0

    Default Re: If no image show no product

    Hi,

    Sorry for the lack of reply, been unavailable for a few weeks.

    The script is missing "<?php" on the first line and "?>" on the last line. They are required to run as php. This script goes through your active product catalog (products_status = 1) and checks to see if the file exists on the file system. If it does and the file is a 4 color jpg ( which may or may not display correctly in a browser ) it converts it - if it can - to a 3 color jpg ( it saves the old version ). If the file is not there, a message will be sent to standard output ( talk about that in a minute ) explaining which file(s) are missing.

    All the output from the script goes to "standard output", which can be handled in different ways by you or your host. In general, hosts take whatever your scripts generate and email it to the admin's email address. So, I get an email everyday with a list of products that are missing or have been converted. In cron, this is how the script is run - could be different on your host.

    /usr/local/bin/php /YOUR_SCRIPT_DIRECTORY/product_image_file_check.php

    Also, this doesn't check for LARGE/MEDIUM images, just whatever is listed in your products table - I use an image handler, so I didn't bother with the other sizes - it could be done though if you needed to.

    Good luck,

    El Coyote
    justteachit

 

 

Similar Threads

  1. v139h Show image on product listing if on special
    By 4jDesigns in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 20 Feb 2012, 04:12 PM
  2. Product Image Doesn't Show
    By cchan in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 13 Jan 2011, 10:11 PM
  3. Show Extra Image In Product Listing.
    By jackson5759 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 28 May 2010, 08:48 AM
  4. Edit Admin Product page to show product image
    By loxly in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 27 Jan 2010, 12:58 AM
  5. Product Info - Show a Bestseller Image
    By NamSingh in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 16 Aug 2008, 10:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR