pavila Posted January 4, 2014 Share Posted January 4, 2014 Hello everyone, My first post in the forum. I need to change the categories shown on the categories tree. Right now, when a category on click from the top menu all the top categories and next depth subcategories are shown as a tree. Instead of a tree, what I need is to have listed all the subcategories which have products associated. How can I achieve this? I already have the SQL necessary to retrieve all the subcategories with products from a certain top category, it will looks something like this: SELECT * FROM ps_category INNER JOIN ( SELECT ps_category.nleft, ps_category.nright FROM ps_category INNER JOIN ( SELECT nleft, nright FROM ps_category WHERE ps_category.id_category = $id_category ) sel_category on (ps_category.nleft<=sel_category.nleft AND ps_category.nright>=sel_category.nright) WHERE ps_category.id_parent = (SELECT id_category FROM ps_category WHERE ps_category.id_parent = 1) ) top_category on (ps_category.nleft>top_category.nleft and ps_category.nright<top_category.nright) WHERE EXISTS (SELECT 1 FROM ps_category_product WHERE ps_category_product.id_category = ps_category.id_category LIMIT 0,1) But where to I have to apply this SQL statement, following the best pratices, etc? Thanks. Kind regards. Pedro Avila Link to comment Share on other sites More sharing options...
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!Register a new account
Already have an account? Sign in here.Sign In Now