i use prestashop 1.6.1.12 I use php 7.1
I have this error message 10 times:
Notice: Undefined offset: 0....override/classes/Category.php on line 18
category.php content is :
<?php
/**
*
*add function for image2 for for class product.php
*
**/
class Category extends CategoryCore
{
public static function getProductsImgSupp($product_id)
{
$sql = '
SELECT id_image, id_product from `'._DB_PREFIX_.'image`
WHERE id_product="'.$product_id.'"
ORDER BY `position` ASC
LIMIT 1,1
';
$result = Db::getInstance()->ExecuteS($sql);
return $result[0]['id_product'].'-'.$result[0]['id_image'];
}
}
Is there a way to correct this error ?
Your sql does not return any records.
2 Reasons for this:
...image
(which may be correct)OR
product_id
which is getting passed to your method is not correct.Case 1:
$result = Db::getInstance()->ExecuteS($sql);
if (empty($result)) {
return null; // you may have to deal with this null if you arent already
}
return $result[0]['id_product'].'-'.$result[0]['id_image'];
Case 2:
Check the code which calls getProductsImgSupp
to see if the right id is passed.