Jump to content

How To Fetch All Images Of A Product On The Category Page


Recommended Posts

I am getting trouble while fetching all images for a product on the category page. For eg :-

i have a product named "abc". There are 3 images for this product. one is cover image and two other images. I want to display all the three images on the category page, currently it only displays the cover image.

Link to comment
Share on other sites

  • 2 months later...
  • 1 year later...

in this case it's necessary to modify controller (categoryController)

you need to add there function with sql query to database to get product images, for example:

public static function getImagesByProductID($id) {

    return Db::getInstance()->ExecuteS('SELECT `id_image` FROM `'._DB_PREFIX_.'image` WHERE `id_product` = '.(int)($id_product));

}

 

then in .tpl file you can use foreach loop on function Category::getImagesByProductID(Tools::getValue('id_product'))

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...