Jump to content

Show all products from a category include all products of subcategories


Recommended Posts

Hello,

 

I have this module on my template. this module show all products from a category id.

Example : Category T-shirts - ID : 19

All products on the id category 19 will be show.

But I have a problem, if I create a SUBCATEGORY called "Movies" on the category and add a product on this subcategory, I can't see this one.

I want to have ALL products from the category and ALL SUBCATEGORIES. not only the first

Example :

     T-shirts      19
          Movies   23
               Star Wars  31
           Anime           44
               DBZ          99
               Naruto      201

 

I have this code on my php module

 

      $arr = explode(",", Configuration::get('CWOSLIDERFEATURED_ID'));
        $categories = array();
        foreach ($arr as $value) {
            $category = new Category($value);
            $cat = array();
            if($category->getProducts((int)Context::getContext()->language->id, 1) != '') {
                $cat['name'] = $category->name[(int)Context::getContext()->language->id];
                $cat['link'] = $category->getLink(null,(int)Context::getContext()->language->id);
                $cat['products'] = $this->prepareBlocksProducts($category->getProducts((int)Context::getContext()->language->id, 1, 16, 'date_add', 'DESC'));
                array_push($categories,$cat);

 

 

Thank you

Link to comment
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...