danielpenalver Posted September 8, 2017 Share Posted September 8, 2017 (edited) Hi there! I'm developing a module that pretends to show 4 featured products on home. Those featured products are chosen by the client CRM/ERP (nowadays i'm just using an array as example). The thing is that i can print product url, title, description, price, etc... but nor the image I generated my module with Prestashop "Module Generator". I tried a lot of things like this: On .tpl (didn't work) <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.name}" /> With this code src would be: http://mydomain.com/-tm_thickbox_default/.jpg Also tried to get the image url from controller.php public function hookDisplayHomeTab(){ global $smarty; $arrayIds = array( 1396, 3193, 3341, 3336 ); //my products real ids $arrayprods = array(); $arraylinks = array(); $arrayimages = array(); foreach ($arrayIds as $id){ $actualProd = new Product($id,null,4); //getting product object array_push($arrayprods, $actualProd); //assign product object $link = new Link(); $url = $link->getProductLink($actualProd); //getting product link array_push($arraylinks, $url); //assign product link $id_image = Product::getCover($id); if ($id_image > 0){ $image = new Image($id_image['id_image']); $image_url = $image->getExistingImgPath().'.jpg'; array_push($arrayimages, $image_url); } } $smarty->assign('productos', $arrayprods); $smarty->assign('links', $arraylinks); $smarty->assign('images', $arrayimages); return $this->display(__FILE__, 'myview.tpl'); } Actually, with this second code I got something like "1/3/6/136.jpg" so I could do www.mydomain.com/1/3/6/136.jpg and see an image, but, this image doesn't match with products selected, they are from other products. It's quite weird because "136" seems to be first product image id (as other checks i made during the process) but when I'm trying to print it i just got another image with no relation. Can anybody help me? What i'm doing wrong? Edited September 8, 2017 by danielpenalver (see edit history) 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