Jump to content

Doing import of product and resizing images


med

Recommended Posts

Hello Community

i am using prestashop 1.7,  I have a 30 000 to import in prestashop, so i want to do it automatiquely into Database. The problem is how to resize the images of my product automaticly us the 5 type of images in prestashop. I wanna know witch class is responsible of resizing images of product that can help me is i call her in my script??

Link to comment
Share on other sites

Hi,

The code is something like this. Just have to replace $tmpfile with your image file.

$image_obj = new Image($id_image);

$path = $image_obj->getPathForCreation();

ImageManager::resize($tmpfile, $path.'.jpg');
 $images_types = ImageType::getImagesTypes($entity);


                foreach ($images_types as $image_type)
                {
                    ImageManager::resize($tmpfile, $path.'-'.Tools::stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']);
                    if (in_array($image_type['id_image_type'], $watermark_types))
                        Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity));
                }

 

But, there are also a few modules on addons.prestashop.com that can help you save a lot of time with importing images.

I wrote an article about this on my blog here: https://developerprestashop.com/blog/prestashop-modules-for-mass-bulk-import-or-upload-product-images/

Hope it helps.

Cheers!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...