Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to random productss per categories?


Tai

Recommended Posts

Thank you Salvo for your link but your code does not for my site that I don't know why? So I tried myself as below

$random_products_category_id = 1;

      if ( (!isset($random_products_category_id)) || ($random_products_category_id == '0') ) {

   $random_products_query = tep_db_query("select distinct p.products_id, pd.products_name,pd.products_short_description, p.products_image, p.products_tax_class_id, IF(s.status, s.specials_new_products_price,p.products_price) as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.status = '1' and c.parent_id = ' " . $random_products_category_id . " order by c.categories_id limit " . MAX_DISPLAY_NEW_PRODUCTS);

 } else {

   $random_products_query = tep_db_query("select distinct p.products_id, pd.products_name,pd.products_short_description, p.products_image, p.products_tax_class_id, IF(s.status, s.specials_new_products_price,p.products_price) as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_id = p2c.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p2c.categories_id = c.categories_id and c.parent_id = ' " . $random_products_category_id1 . "' and c.status = '1' and p.products_status = '1' order by  c.categories_id limit 5,1");

 }

I copied from from new_products.php and change just a little bit.

It works but I think it is too long which not same as your code.

Link to comment
Share on other sites

That was for a Nov 2002 snap..

 

Maybe something has changed unless I have changed it once installed...

 

Tonight I try the code I have in MS1 and let you know....

 

Salvo

Link to comment
Share on other sites

  • 4 weeks later...
That was for a Nov 2002 snap..

 

Maybe something has changed unless I have changed it once installed...

 

Tonight I try the code I have in MS1 and let you know....

 

Salvo

 

What did you find out?

Webz -------> @(-_-)@

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...