Reputation: 63
I want to find Product image url stored location in Prestashop Database.
Upvotes: 5
Views: 15470
Reputation: 5748
Product image urls are not stored in database. The location is based on the id_image
field of ps_image
table.
An image having 1234
for id will be stored under /img/p/1/2/3/4/1234.jpg
.
An image having 1514
for id will be stored under /img/p/1/5/1/4/1514.jpg
.
I invite you to check /classes/Image.php
and /classes/ImageManager.php
for more informations.
Upvotes: 12
Reputation: 910
As stated in earlier answers, the URL of the images is built using the id_image
field (stored in ps_image
table) related to a given product.
Here is a (simplified) SQL query to retrieve id_image
value for each product:
SELECT ps_product.id_product, ps_image.id_image
FROM ps_product, ps_image
WHERE ps_image.id_product = ps_product.id_product AND ps_image.position = 1
And here is how to build related URLs :
// [...] run SQL query and fetch an array of resulting rows
foreach($rows as $row) {
$url = '/img/p/'.implode('/', str_split((string) $row[1])).'/'.$row[1].'.jpg';
}
Hope this helps ...
Upvotes: 0
Reputation: 985
As told by Floarian images are stored in {DB_PREFIX}image
table and located in img/p
folder based on id of the image.
If you have moved images as per new system, your images are located as told by Floarian but url of image will be like..
{YOUR_SITE_URL}/img/p/{ID_IMAGE}-{IMAGE_TYPE}/{FRIENDLY_URL_OF_PRODUCT}.jpg
e.g.
www.testsite.com/img/p/1234-home_default/my-test-product.jpg
Upvotes: 4