kpl Posted September 1, 2015 Share Posted September 1, 2015 Lets assume I have a category tree four or more levels deep: Level 1 - root Level 2 - main categories Level 3,4... - subcats What I want to achieve is to have category tree displayed in this way: Level 1 - no category block displayed (done) Level 2 - show selected main category full tree Level 3,4... - show the same as level 2 - selected main category full tree What I know is that I have to modify blockategories.php file ad play with lines 184-190 to make it work. The problem I have is propably simple - instead of current or nearest parent category id, I should pass the value of Level 2 parent category id. But I don't know how to get this id... For the time being, I made it in the worst possible, non flexible way: if($category->id=='9' || $category->id=='10' || $category->id=='11' || $category->id=='36') { $category->id_parent=3; } So this works only as long, as current category structure is kept. I need flexible solution for assigning correct " $category->id_parent=???". Thanks in advance! Link to comment Share on other sites More sharing options...
polosat Posted September 1, 2015 Share Posted September 1, 2015 Try something like this: foreach ($category->getParentsCategories() as $cat) { if($cat['level_depth'] == 2) { $id_parent = $cat['id_category']; break; } } Link to comment Share on other sites More sharing options...
andredutton Posted September 2, 2015 Share Posted September 2, 2015 Ola, Sou novo na área de desenvolvimento web, e leigo em relação ao presta shop. a minha duvida e se existe algum recurso ou modulo em que eu possa cadastrar sub produtos dentro de um único item. Vou me expressar melhor: Exemplo: http://www.pitocopecas.com.br/ quando clico em um item, aparece mais sub produtos. Link to comment Share on other sites More sharing options...
kpl Posted September 3, 2015 Author Share Posted September 3, 2015 Thanks polosat, it looks, likie it's a good direction, but it didn't solve problem - it works only for this depth - what would you reccomend to make it work for deeper levels? Link to comment Share on other sites More sharing options...
polosat Posted September 5, 2015 Share Posted September 5, 2015 What levels do you mean? That code returns a level 2 parent for any category.$category is a category object that you already have, $id_parent is a result that you can use later. I used $id_parent as a result in the previous code for illustration, try this one instead: foreach ($category->getParentsCategories() as $cat) { if($cat['level_depth'] == 2) { $category->id_parent = $cat['id_category']; break; } } 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