Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Only Return Query for Items with Images


Recommended Posts

Hi All,


I spent some time looking for a quick fix to this problem without finding any threads or contributions that solved the problem adequately, but found a solution here. This fix makes it so that items that have been entered without images are NOT displayed in user search results. This is great if you are entering a large number of items, don't have photos for all of them, but would like to go ahead and begin selling those for which you do. It seems like this should be a standard option within the image display menu of configuration.php:


Simply paste this code:


// only display products with images entered

$listing_sql .= " and length(p.products_image)>0 ";


Immediately before:


if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {

if ($column_list[$i] == 'PRODUCT_LIST_NAME') {

$HTTP_GET_VARS['sort'] = $i+1 . 'a';


in catalog/index.php. Hope this helps someone. b

Link to comment
Share on other sites

Furthermore, to extend this functionality to search results, add the following code to catalog/advanced_search_result.php around line 303:


// only return products with images

$where_str .= " and length(p.products_image)>0 ";



immediately before:


if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { ....

Link to comment
Share on other sites

although this works, the actual length of the products_image field is irrelevant, thus I would think that (mind the double single quote for the empty string)


$where_str .= " and p.products_image <> '' ";


would be (slightly) more performant


I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!


Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...