Prestashop image URL

Here is the tested code, I put this code in test.php under root directory of my prestashop installation and it works awesome.

<?php
require_once dirname(__FILE__).'/config/config.inc.php';
require_once dirname(__FILE__).'/init.php';

$id_product = 1; // set your product ID here
$image = Image::getCover($id_product);
$product = new Product($id_product, false, Context::getContext()->language->id);
$link = new Link; // because getImageLink is not static function
$imagePath = $link->getImageLink($product->link_rewrite, $image['id_image'], 'home_default');
echo $imagePath;

From your code you should be aware that getImageLink is not static function and your first block of code snippet $product is not initialized with any product.

Tags:

Prestashop