Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[ADDON] Hide Categories with category cache


Denzel

Recommended Posts

Hi Forum,

 

I have found the Supportthread for this contrib closed, so I open my own...  B)

 

Does anyone use this contrib and has products in multiple categories ? It stores the hidden categories ids in the $hiddencats array.

 

In my shop the products_new.php displays the products as often as they are joined with different categories.

The build in sql does the correct thing, but if I hide some (or one) category, the bug appears.  

 

My shop is a 2.3 BS Edge one. Here are the querys:

  if (!empty($hiddencats)) {
  $listing_sql = "select " . $select_column_list . " p.products_id, SUBSTRING_INDEX(pd.products_description, ' ', 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = pd.products_id and p.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and (not (p2c.categories_id in (" . implode(',', $hiddencats) . ")))";
  } else {
  $listing_sql = "select " . $select_column_list . " p.products_id, SUBSTRING_INDEX(pd.products_description, ' ', 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";
  }

This is the buggy for better view:

select p.products_image, 
       pd.products_name, 
       p.products_id, SUBSTRING_INDEX(pd.products_description, ' ', 20) as products_description, 
       p.manufacturers_id, 
       p.products_price, 
       p.products_tax_class_id, 
         IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, 
         IF(s.status, s.specials_new_products_price, p.products_price) as final_price 
from products_description pd, 
     products_to_categories p2c, 
     products p 
left join manufacturers m on p.manufacturers_id = m.manufacturers_id 
left join specials s on p.products_id = s.products_id 
where p.products_status = '1' and 
      p.products_id = pd.products_id and 
      p.products_id = p2c.products_id and 
      pd.language_id = '2' and 
      (not (p2c.categories_id in (48,48))) 
order by p.products_id DESC limit 0, 20


Maybe there is a SQL-Crack here, who can help me...  :D

 

SEE YA

Denzel.

Link to comment
Share on other sites

Hello Denzel @@Denzel,

 

for me it would sound more familiar at the end like this:

pd.language_id = '" . (int)$languages_id . "' and (p2c.categories_id not in (" . implode(',', $hiddencats) . "))";
  } else {
pd.language_id = '2' and 
      (p2c.categories_id not in (48,48)) 
order by p.products_id DESC limit 0, 20

but I may be wrong.

 

Merry Christmas

Rainer

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...