Two Categories block in prestashop


Two Categories Block:

Most people using prestashop want to know how to get that here are some solutions to get that one

First solution is like that You can use the manufacturer block as the second category block.

Example

If you are adding a product  in BO then You also include the manufacturer name,Instead of manufacturer you can add the category name in it so that product is available in two blocks

Suppose you are also needed the manufacturer block in Your shop means then go for the second solution

Second solution:

Categories that you are used in the separate blocks to be given in the Sub-Subcategories in BO

Steps:

1. Go to your modules folder and make a copy/duplicate of your blockcategories folder and rename it with blockcategories2 for example.
2. Enter in the blockcategories2 folder and rename the blockcategories.tpl and blockcategories.php to blockcategories2.tpl and blockcategories2.php.
3. Open up your blockcategories2.php and replace all blockcategories words to blockcategories2.
4. In blockcategories2.php find this string:

function getTree($resultParents, $resultIds, $maxDepth, $id_category = 1, $currentDepth = 0)

In $id_category = 1 replace the 1 with your desired subcategory id number

5.Open your blockcategories2.tpl and in line 5 replace the Categories string with your desired block name.For example i have used this for one of my blocks:

{l s=‘Perifericos’ mod=‘blockcategories’}

That´s all,if you use a language that is not english open up your languague file in the blockcategories2 folder and rename all the blockcategories strings to blockcategories2

Thats It your done!

About

Working For Cause Not For Applause

Tagged with: , , , ,
Posted in Prestashop
37 comments on “Two Categories block in prestashop
  1. mani says:

    hey.. got to stumble on ur blog when i was querying for a feature in prestashop. Im yet to find it. My question – There is only one parent category in Prestashop, which is ‘Home’. Is there a way to create multiple parent categories in Prestashop.
    It would be very helpful for me if i get to know the answer. Thanks.

    • dharanid says:

      Hey Mani ,
      Now its not possible in the prestashop, But you can create sub categories in the home category and use that sub category as a main category by this line
      ($resultParents, $resultIds, $maxDepth, $id_category = 1, $currentDepth = 0) where you can replace the category id of your sub category.

  2. Daan says:

    Hi,

    thanks a millions for the solution! I tried >> for the most it worked.

    I have a question, though: Is it possible to hide a subcategory in module blockcategories which you only want to show in blockcategories2 ?

    Thanks in advance for your time!

    Greetings,

    Daan Tol

  3. Robert says:

    Hi, thanks for your explaintion. I managed to make subcategories. But do y know how to fix this: if i activate the subcatgorie2 (prijs) it is shown in the both the blocks, i only want it offcourse in the 2th categorieblock. ??

    Thanks i adv. Robert

    • dharanid says:

      Robert,
      i cant get your question properly can you please elaborate so i can help you………

      • dharanid says:

        I think your problem is one category block has the category id no1 and the other block category is category id no2 ….. In prestashop category ID no 1 represents the home category so every parent category falls under the parent category home. so its not possible to avoid the 2nd category block in the first category block …..

  4. Spazzo says:

    hi,

    I did the steps to duplicate the blockcategories and gave it id = 99 as a random number. i did have 2 but thought it may be a problem. my problem is, that it is not showing up in the catalog. How do i make it appear so i can add to it?

    regards
    Spazzo
    thanks

    • dharanid says:

      Hi Spazzo,
      you should not have to give random no like 99 if there is any category id called 99 means you can give it as 99 else it wont appear in front end… just give the category id available in your catalog

  5. Spazzo says:

    Sorry i wasn’t clear for you. My problem is that i installed the blockcategories2 but i can’t see where it supposed to show up so i can add to it. Can you please explain where it is supposed to appear and why i can’t see it.

    thanks
    regards
    Spazzo

    • dharanid says:

      Its Not showing in the front end because of the category id=99 Because There is no category id 99 in your catalog.If its available means only it will display bro.And one more important thing is that will display only the sub categories under the category id=99.

  6. Spazzo says:

    I installed the blockcategories2. I see it in the front office in the left column. I can not see it or find it in the back office. How do i see it and add subcategories to this block?

    thankyou

  7. Dharani says:

    Hi Spazzo,
    Its very simple add new categories in your back end and set the parent category as category id that you used in the block category module2.

  8. Spazzo says:

    Sorry but i can’t see where to enter category id, i can’t see where to add new categories. All i can see is the normal categories and where to add new subcategories & products.

    • Dharani says:

      Here are the steps to create sub categories
      After You Login to the backend of the prestashop.You will see the menus in the top,go and click the catalog menu in that there you can see a + symbol followed by add sub categories click that then you will carried through a form where you have to select the parent category as the category that you edited in block categories2.

      • Criss says:

        Hello Dharani,
        I have the same problem as Spazzo. I folowed all the steps, I have a new category in front office but in the back office this new category doesn’t appear next to the other categories so I can’t add a new subcategory to it (since I can’t see it). This new category doesn’t appear as a parent category, it doesn’t appear at all.
        I am not sure if you’re still folowing this matter but your help would be much appreciated.
        Thank you and take care.

  9. Spazzo says:

    Sorry but i am terrible at explaining things. I cant see any blockcategories2 int the Parent Category. That is what i am having trouble with.

    regards
    Spazzo

  10. Spazzo says:

    Would you be able to have a look at this html file. I have pasted the code from blockcategories2.php & blockcategories2.tpl . Could you please see if i have done the changes correctly thanks?

    http://www.myblackhandbag.com.au/BC.html

    regards
    Spazzo

  11. amit says:

    Hello dharani, I followed your solution to create a copy of blockcategories. I created a new category in the back office panel with id 6 called location. Then, I created a copy of blockcategories module as blocklocation and put in the category id 6 in the gettree function call in the php file. However, I am not able to see the new block on the front-end or under the modules tab of the back office. Any idea why? Your help is much appreciated.

  12. Hacktor says:

    In de main category you see Catblok2 and Catblok3. In the other two blocks it has to display Catblok2 and Catblok3 but it displays the sub-category Catblok2sub and Catblok3sub.
    Can you help me to fix this. Catblok2sub must be Catblok2 and Catblok3sub must be Catblok3.
    I’ve changed the $id_category = 1 into:
    function getTree($resultParents, $resultIds, $id_category = 5, $currentDepth = 0)
    function getTree($resultParents, $resultIds, $id_category = 8, $currentDepth = 0)

  13. Spazzo says:

    Go to this website as they have instructions to add multiple category blocks

    http://www.redfoxblackbox.com

  14. mohan says:

    is it possible to display Categories block in all products related to one category? Please help me on this

  15. hi dharani, what can i say but a very good blog on prestashop. is there any solution to make list of category appear in the cms block.

    i have tried merging the blockcateogry.tpl and blockcateogry.php to blockcms.tpl and blockcms.php and it shows all the available category but only sometime not always and on refreshing the page it get disappeared.

  16. Haseeb says:

    Hey,
    This is an out standing blog. Dude i would like to ask you one thing, is it possible to add parent category when sub-category contains products in Prestashop?

    • dharanid says:

      Hi haseeb,
      Thanks for your valuable comments.
      I think you can create sub category from your category list not parent category.
      I’m not sure of the answer because now i’m not concentrating on prestashop,
      so better you ask this in prestashop forum…. they will help you for sure

  17. Sandrine says:

    Hi Dharanid,

    Thanks a lot for your post, I am a “beginner” in Prestashop and even in creating sites and by following your post, I have succeeded in creating a subcategory menu on my left column….
    So I have decide to create a new one and have done the same process replacing 2 by 3, changing the ID of category and changing the block name…And Oups it doesn’t work…The menu and sub-categories appear on font office but the block name doesn’t appear: its’blank…I’ve tried and tried trying creating new modules but it nevers worked and I don’t know why???
    Can you help?

    • dharanid says:

      Can you explain a little bit…
      What i understood is ,that you can get your subcategories, but not getting the block title
      Is it right?

      • Sandrine says:

        Sorry for this late answer but I have found my answer one week after my mail and before you answered and after that, I totaly forgot to answer…Sorry again
        In fact, it works very well….The problem is that Prestashop lacks of memory and when you disable “smarty”, it works…

        Thanks again for your tutoriel, it’s really helped me.

  18. Dear Dharanid ,

    Why I can not show my subcategories for my second categories?

    Thanks in advance

  19. alberto says:

    Thank you for your short tuto, now I know how to display a custom list of categories on the module 😉

  20. Carlos says:

    The edit worked perfectly. Thank you for making this tutorial.

    One question — the footer? I am going to try to figure that out on my own but if you happen to have a solution already that would make an excellent addendum to this tutorial.

    If I figure it out I’ll come back and post a solution.

  21. christiaan says:

    Hi, a little late response, but thanks for the blog.

    I installed the module and it shows where I want it, only the categories do not show up in the 2nd categories block. It seems like it doesn’t take the new category ID, which I enter in the .php file, in this line: ‘function getTree($resultParents, $resultIds, $maxDepth, $id_category = 1’. On default it doesn’t say 1, but ‘null’. When I enter the ID number, for example 135, nothing happens. When I redo it to null it gives the same category list as the first categories block.

    Thanks for any help.

  22. christiaan says:

    Never mind the last post. It had to do with the depth in the settings of the module. It’s fixed now. Wonderful solution! Thanks.

  23. Odeen says:

    Hello,
    i am trying this tutorial to use on prestashop 1.5.4.1 and it is sadly not working for me.
    Also i were looking solution elsewhere, but there is nothing.
    Anyone updated it? Or is there possibility that dharanid will update this tuto?
    Please… 🙂

    • Carlos says:

      It works fine on 1.5.4.1 so if it is not working for you then you have made a mistake. Unfortunately I can’t offer more help since I can’t see what you’ve done. I have four blocks using this method on 1.5.4.1

      One thing that maybe wasn’t clear that might be the issue is that once you edit the code you must still install the new Category Block module. So do all the editing then go to modules and you should see two Category Block modules. One will be installed and the other will be waiting to be installed. Install the new one and you should have two blocks now.

  24. dharanid says:

    Odeen,
    I can make this work in prestashop v 1.5.5.
    Try to change it in core initially and then Duplicate It.

    I will update this tutorial when i get time.

Leave a reply to Spazzo Cancel reply