Reputation: 130
I have 2 prestashop stores hosted in the same ftp with the same products one of them have all the images loaded (Over 9k) and the other has none, I want to know from what controller and function does prestashop loads the images.
I know the images are stored inside /img/p {digits with slashes}/product_id.jpg so the only thing I'm missing is the place where the images are loaded in the front end so I can alter that function and make it point to the photos of the other shop in order to avoid the job of uploading each of the photos on the second store.
I have php knowledge so I'm looking for a way to "hardcode" this functionality. Knowing that its not the proper way to work it I'm looking to develop a script that allows me to do this.
Upvotes: 1
Views: 1029
Reputation: 689
Product's images routes are not related to product id
, but related to image id
. For example: id_image =35 route should be /img/p/3/5/35.jpg
You can find relation between image and product in ps_image
table in DB.
Images link are dynamically formed in Link::getImageLink
function located at classes/Link.php
. If you want to do some modification this is the best place to do it.
Gook luck
Upvotes: 1
Reputation: 1301
go to your backend Vaii and in the products page, you will find the Export button.
In csv there in the first two columns id and url image.
include(dirname(__FILE__).'/../../config/config.inc.php');
//Customize it so you have <product id> and <your ur photo>
$image = new Image();
$image->id_product = (int) <product id>;
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = true;
$image->add();
$photo_url = <your ur photo>;
copyImg($id, $image->id, $photo_url, 'products', !Tools::getValue('regenerate'));
Upvotes: 1