Jump to content

[Solved] Problems on getting id_image, help needed

MEG Venture

Recommended Posts



I am trying to build a new module and to do that I use the below php function to call product variables.


function hookHome($params)
 global $smarty, $cookie;
 $limit = (int)Configuration::get('VIDEO_PRODUCTS_NBR');
 $videoProducts = Product::getProducts((int)$params['cookie']->id_lang, 0, ($limit ? $limit : 10), 'id_product', 'ASC', false, false);
 $videoProducts = Product::getProductsProperties((int)$params['cookie']->id_lang, $videoProducts);
	if ($videoProducts) {
 if ($videoProducts)
  foreach ($videoProducts AS $videoProduct)
$video_products[] = $videoProduct;
 $smarty->assign('video_products', $video_products);


However, when I try to call image urls, some of them is with correct id_mage, but some of them is has id_image variable returns having "en-default". That's why, image is not displayed.


Here is the code I use to call image links:


<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home')}" alt="{$product.name|escape:html:'UTF-8'}" />


If anyone can help me to fix this problem, I'll appreciate a lot.


P.S: My environment is Prestashaop 1.4.x but I am having the same issue on 1.5.x, too.



Edited by MEG Venture (see edit history)
Link to comment
Share on other sites

  • 10 months later...



I used the products assigned to the home category like the homefeatured products module. Here is my code for Prestashop 1.5.x

	function hookDisplayHome($params)
		global $smarty;

		$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
		$limit = (int)(Configuration::get('VIDEO_PRODUCTS_NBR'));
		$video_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($limit ? $limit : 10));

			'video_products' => $video_products,
			'homeSize' => Image::getSize('home_default'),

		return $this->display(__FILE__, 'productvideoslider.tpl');		

and on the tpl 

<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" />

I hope that helps 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...