Jump to content

[SOLVED] how to - Home Featured module showing variety of products


aljon1234
 Share

Recommended Posts

in my module homefeatured.php, i know how to specifically show a categories of homefeatured item like this

 

$category = new Category(4, (int)Context::getContext()->language->id);

 

my problem is i wanted to show all the catergories id like this

 

$category = new Category(4, (int)Context::getContext()->language->id);

$category = new Category(5, (int)Context::getContext()->language->id);

$category = new Category(6, (int)Context::getContext()->language->id);

$category = new Category(7, (int)Context::getContext()->language->id);

 

.. so how will i do this?

 

how can i show multiple categories item in the home page

Share this post


Link to post
Share on other sites

you have to create separated variables like

$category1

$category2

$category3

...

...

 

then in module homefeatured.tpl file create another foreach loop on these variables (just copy and paste, and change variable)

 

 

or just you can use array_merge() code to merge two $category1->getProducts() and $category2->getProducts() functions results

  • Like 1

Share this post


Link to post
Share on other sites

Instead of using this i tried 

 

            $cat=$category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), "position");
            $cat1=$category1->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), "position");
         

$products = array_merge($cat,$cat1) ;

 

 

this method is easier and the code is shorter .. thanks

Edited by aljon1234 (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

  • 4 months later...
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More