Uploaded image for project: 'Prestashop 1.6'
  1. Prestashop 1.6
  2. PSCSX-6462

Problem with product id_image, causing the product cover image not shown when add to cart (popup window), in block cart, and in shopping cart summary


    • Type: Bug
    • Status: Closed
    • Resolution: Duplicate
    • Affects Version/s:
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All-users
    • Labels:


      This problem happening when Combinations feature was disabled at
      B.O > Advanced parameters > Performance

      When you click "Add to cart" button, the product cover image won't be displayed correctly in add to cart popup window.
      After the product has been added to the cart, the product cover image won't be displayed correctly in blockcart and shopping cart summary.

      This problem happening because in the Cart.php classes file at getProducts method, the sql select query doesn't state the required variable to get product id_image from the database.

      inside if (Combination::isFeatureActive())
      there are sql leftJoin query which handle this, but then if the Combination feature was disabled, those sql leftJoin doesn't included.
      Therefore the id_image value will ending up with a value :
      e.g : en-default
      Also there is a small mistake within the sql select query in the if statement, in there was stated :

      image_shop.`id_image` id_image,


      image_shop.`id_image` AS id_image,

      (with AS)

      To solve this problem, the clasess file Cart.php at getProducts method should be modified as following :
      01. Place the related sql leftJoin query outside if/else statement
      02. At the else statement, add the necessary statement into the sql select query :

      image_shop.`id_image` AS id_image, il.`legend`

      The complete fix will be look like this :

      Cart.php - getProducts
      		if (Combination::isFeatureActive())
      				product_attribute_shop.`price` AS price_attribute, product_attribute_shop.`ecotax` AS ecotax_attr,
      				IF (IFNULL(pa.`reference`, \'\') = \'\', p.`reference`, pa.`reference`) AS reference,
      				(p.`weight`+ pa.`weight`) weight_attribute,
      				IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13,
      				IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc,
      				image_shop.`id_image` AS id_image, il.`legend`,
      				IFNULL(product_attribute_shop.`minimal_quantity`, product_shop.`minimal_quantity`) as minimal_quantity,
      				IF(product_attribute_shop.wholesale_price > 0,  product_attribute_shop.wholesale_price, product_shop.`wholesale_price`) wholesale_price
      			$sql->leftJoin('product_attribute', 'pa', 'pa.`id_product_attribute` = cp.`id_product_attribute`');
      			$sql->leftJoin('product_attribute_shop', 'product_attribute_shop', '(product_attribute_shop.`id_shop` = cp.`id_shop` AND product_attribute_shop.`id_product_attribute` = pa.`id_product_attribute`)');
      				'p.`reference` AS reference, p.`ean13`, image_shop.`id_image` AS id_image, il.`legend`,
      				p.`upc` AS upc, product_shop.`minimal_quantity` AS minimal_quantity, product_shop.`wholesale_price` wholesale_price'
      		// the sql leffJoin should be placed outside if/else statement
      		// so no matter combinations feature is enabled or disabled
      		// the required variable will be included
      		$sql->leftJoin('image_shop', 'image_shop', 'image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop='.(int)$this->id_shop);
      		$sql->leftJoin('image_lang', 'il', 'il.`id_image` = image_shop.`id_image` AND il.`id_lang` = '.(int)$this->id_lang);


          Issue Links



              • Assignee:
                Gregory Gregory
                gonebdg Hargono Setiadi
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: