Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Excluding categories from new_products.php module


Franck

Recommended Posts

Hello,

 

I've created a special "featured products" module that I will be displaying on my homepage; it just gives larger illustrations and more product information than the usual new_products.php module.

 

However, I'm also using the standard new_products module on my homepage. So obviously I want to exclude from it the products I'm featuring elsewhere.

 

I'm not familiar enough with SQL to work this out.

 

Say my featured products are all in category id 30, how do I exclude this category from the standard new products module... (if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) because I'm not allowing users to select categories.

 

Hope somebody can help me over this hump.

 

Many thanks,

Franck

Link to comment
Share on other sites

It would be easier to simply exclude your featured items rather than exclude a category.

 

So - how are you marking your featured items?

 

Well, all my featured items belong to a single category... And if it's simpler to exclude "featured items" can you tell me how you'd mark those items to exclude them from the standard new products module.

 

In any event, here's the SQL query for my featured items (all category id 30):

 

$featured_products_query = tep_db_query("select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, pd.products_description from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES. " c on (p.products_id = c.products_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and c.categories_id = '30' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

Link to comment
Share on other sites

I've solved my problem: Here's the modified code for new_products.php module:

 

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

$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES. " c, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = c.products_id and c.categories_id != '30' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

} else {

$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id != '30' and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

}

Link to comment
Share on other sites

  • 1 year later...

Archived

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

×
×
  • Create New...