pixelmary Posted January 11, 2019 Share Posted January 11, 2019 (edited) Hi everybody and thanks for the support. I would like to know if you can help me to get two images for each product in product-list.tpl, I have seen several responses about this subject associated with PS 1.6, but obviously, they are not useful for 1.7. I can not find the solution because I prefer not to install a module just for this. I appreciate your help very much! Maybe this links I've found can be useful. https://stackoverflow.com/questions/40267160/how-to-display-in-product-list-the-cover-image-and-the-second-image-of-a-product Edited January 11, 2019 by pixelmary Add link recources (see edit history) Link to comment Share on other sites More sharing options...
waixo Posted October 23, 2019 Share Posted October 23, 2019 I don't know if you solve it but I solved it and it works perfectly in PS 1.7. /** FILE /override/classes/controller/ProductListingFrontController.php **/ <?php abstract class ProductListingFrontController extends ProductListingFrontControllerCore { private function prepareProductForTemplate(array $rawProduct) { $product = (new ProductAssembler($this->context)) ->assembleProduct($rawProduct); $presenter = $this->getProductPresenter(); $settings = $this->getProductPresentationSettings(); $productOut = $presenter->present( $settings, $product, $this->context->language ); // Force delete this value from the ProductListingLazyArray > ProductLazyArray. Cya! $productOut->offsetUnset('main_variants', true); // Regenerate (performance hit). $mainVs = $productOut->getMainVariants(); $id_image = Db::getInstance()->ExecuteS('SELECT `id_image` FROM `'._DB_PREFIX_.'image` WHERE `id_product` = '.(int)($product['id_product'])); $link = Context::getContext()->link; $product_images = array(); foreach($id_image as &$image){ array_push($product_images, $link->getImageLink($product['link_rewrite'], $image['id_image'], 'large_default')); } $productOut->__set('product_images', $product_images); //print_r($productOut); //echo "\n"; return $productOut; } } And then in product.tpl /** FILE product.tpl inside catalog/miniatures/product.tpl **/ {foreach from=$product.product_images item=image} <div class="product-image"> <a href="{$product.url}" class="thumbnail product-thumbnail"> <img class="img-fluid" src = "{$image}" /> </a> </div> {/foreach} I hope will help someone, for me it's useful and you don't need any module. See you! Link to comment Share on other sites More sharing options...
MOB000 Posted December 3, 2019 Share Posted December 3, 2019 Hello Waixo, In product.tpl where should we paste the code ? Thank you 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