How does prestashop loads Images?

人走茶凉 提交于 2020-01-03 01:42:51

问题


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.


回答1:


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




回答2:


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'));


来源:https://stackoverflow.com/questions/41289453/how-does-prestashop-loads-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!