Jump to content

[SOLVED] ziadny watermark pri importe z csv


eriqx

Recommended Posts

Zdravim,
chcem sa opytat, ci neviete niekto ako sa da pri importovani produktov s obrazkami nastavit, aby sa k obrazku pridal watermark. Ked pridam obrazok cez back office, tak sa watermark normalne vygeneruje.
Dakujem za odpoved

Link to comment
Share on other sites

Tak som na to prisiel nakoniec aj sam :)
Ak by to niekoho zaujimalo, tak stacilo trochu zmenit funkciu copyImg v admin\tabs\AdminImport.php
Tu je cela funkcia:

private static function copyImg($id_entity, $id_image = NULL, $url, $entity = 'products')
   {
       $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import');
       $sel_types = explode(',', Configuration::get('WATERMARK_TYPES'));

       switch($entity)
       {
           default:
           case 'products':
               $path = _PS_PROD_IMG_DIR_.intval($id_entity).'-'.intval($id_image);
           break;
           case 'categories':
               $path = _PS_CAT_IMG_DIR_.intval($id_entity);
           break;
       }

       if (@copy($url, $tmpfile))
       {
           imageResize($tmpfile, $path.'.jpg');
           $imagesTypes = ImageType::getImagesTypes($entity);
           foreach ($imagesTypes AS $k => $imageType) {
               imageResize($tmpfile, $path.'-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']);             
               if (in_array($imageType['id_image_type'], $sel_types)) {
                   Module::hookExec('watermark', array('id_image' => $id_image, 'id_product' => $id_entity));
               }                
           }
       }
       else
       {
           unlink($tmpfile);
           return false;
       }
       return true;
   }

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...