Jump to content

how to get the product default image from the product name?


Recommended Posts

Hi,

I want to know by which pattern prestashop shows the product default image? I mean lets say I have a mysql query for prestashop like this



SELECT ps_product.id_product,ps_product.id_category_default,description_short,ps_product_lang.name FROM ps_product_lang,ps_product WHERE ps_product_lang.id_lang=1 AND ps_product.id_product=ps_product_lang.id_product


 

Now here I will get the product id, product category, description, and name.

Now according to prestashop default products and database I have for the product iPod Nano the database fields are like



id_product  id_category_default
  1               3            


  Now if I want to get the product image I will use 


img/p/id_product/id_category_default/id_product.id_category_default

  This will make the img src like



img/p/1/3/13.jpg


  Now when I used that I got the image for Belkin Leather Folio for iPod

  

  but with the same condition I got the exact image for ipod shuffle. So can someone kindly tell me how to get the exact default image for the product name? Any help and suggestions will be reallyu appreciable. Thanks

 

Link to comment
Share on other sites

 

Hi,
I want to know by which pattern prestashop shows the product default image? I mean lets say I have a mysql query for prestashop like this
SELECT ps_product.id_product,ps_product.id_category_default,description_short,ps_product_lang.name FROM ps_product_lang,ps_product WHERE ps_product_lang.id_lang=1 AND ps_product.id_product=ps_product_lang.id_product
 
Now here I will get the product id, product category, description, and name.
Now according to prestashop default products and database I have for the product iPod Nano the database fields are like
id_product  id_category_default
  1               3            
  Now if I want to get the product image I will use 
img/p/id_product/id_category_default/id_product.id_category_default
  This will make the img src like
img/p/1/3/13.jpg
  Now when I used that I got the image for Belkin Leather Folio for iPod
  
  but with the same condition I got the exact image for ipod shuffle. So can someone kindly tell me how to get the exact default image for the product name? Any help and suggestions will be reallyu appreciable. Thanks

 

Any solution from experts?

Link to comment
Share on other sites

  • 1 year later...

I'm not sure if this can help, but you can try this:

 

SELECT

ps_product.id_product,
ps_image.cover,
ps_image.id_image
FROM
ps_image
INNER JOIN ps_product
ON ps_image.id_product = ps_product.id_product
WHERE
ps_image.cover = 1
 
And then
 
http://yourshop/prestashop/{id_image}-cart_default/img.jpg
 
cart_default can be replaced by any value of name in table ps_image_type.
 
You can also check "public static function getCover" in classes/Product.php
 
Hope it helps someone.
 
Eder
Link to comment
Share on other sites

  • 1 month later...
×
×
  • Create New...