karolitg Posted March 25, 2016 Share Posted March 25, 2016 Hello,I have a problem with PrestaShop. I do shop for my friend, and he wants to number of product in category menu (left_column). In shop will be many products, and many (multi-level) categories.I think that it's not good idea, because every refresh of website I will calculate number of product in every category.-> I don't know how I can do this. Because, if I refresh website, I must calculate number of products. It's not efficient. -> Second problem is- i don't know how i can do this in PrestaShop controller. What you think about this problem? Link to comment Share on other sites More sharing options...
karolitg Posted March 25, 2016 Author Share Posted March 25, 2016 Yes, but in left column.In attached is examples with standard PrestaShop template. Link to comment Share on other sites More sharing options...
karolitg Posted March 26, 2016 Author Share Posted March 26, 2016 Thanks for your answer.Yes, I know, but I see in sql code of module, and if I do join with products, my query will be very slow (if in shop will be many products, and many categories - now I have a 100 categories, and a few products. But in future, in this shop will be maybe 3000-4000 products.).I don't want to slow this shop, but I don't know, how I can do it this modification in other way that add sql join to products table. Link to comment Share on other sites More sharing options...
andreea91 Posted November 19, 2018 Share Posted November 19, 2018 Hello, how do I make it work in 1.6.11, because the code is different? Thank you Link to comment Share on other sites More sharing options...
andreea91 Posted November 20, 2018 Share Posted November 20, 2018 16 hours ago, ndiaga said: The method is the same, just adapt the code based on error reportings. Hello again, I tried many times but no results :)) My code is below: public function getTree($resultParents, $resultIds, $maxDepth, $id_category = null, $currentDepth = 0) { if (is_null($id_category)) $id_category = $this->context->shop->getCategory(); $children = array(); if (isset($resultParents[$id_category]) && count($resultParents[$id_category]) && ($maxDepth == 0 || $currentDepth < $maxDepth)) foreach ($resultParents[$id_category] as $subcat) $children[] = $this->getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1); if (isset($resultIds[$id_category])) { $link = $this->context->link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']); $name = $resultIds[$id_category]['name']; $desc = $resultIds[$id_category]['description']; } else $link = $name = $desc = ''; $return = array( 'id' => $id_category, 'link' => $link, 'name' => $name, 'desc'=> $desc, 'children' => $children ); return $return; } Link to comment Share on other sites More sharing options...
andreea91 Posted November 20, 2018 Share Posted November 20, 2018 (edited) and where can I put this code? Edited November 20, 2018 by andreea91 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now