Jump to content

images are not display after import from xml


Recommended Posts

Hi,

 

I wrote my own script for import products from xml. I have a fucntion for addimage from xml

function addImage($id_product,$file,$cover,$position)
{
    $flag = Db::getInstance()->insert('image',array(
        'id_product' => $id_product,
        'position'=> $position,
        'cover' => $cover
    ));

    $id_image = Db::getInstance()->Insert_ID();

    $flag = Db::getInstance()->insert('image_lang', array(
        'id_image' => $id_image,
        'id_lang' => 1,
        'legend' => 'test'
    ));

    $flag = Db::getInstance()->insert('image_shop', array(
        'id_image' => $id_image,
        'id_shop' => 1,
        'cover' => $cover
    ));


    $imagesTypes = ImageType::getImagesTypes('products');

    $id_image = Db::getInstance()->Insert_ID();
    $path_d = _PS_IMG_DIR_.'p/'.$id_image;
    $path = _PS_IMG_DIR_.'p/'.$id_image.'/'.$id_image.'.jpg';
    mkdir($path_d);
                      
    $data = file_get_contents($file);   
    $fp = fopen($path, 'w');
    fwrite($fp, $data);
    fclose($fp);

    $sourceFile['tmp_name']= $path;
    
        foreach ($imagesTypes AS $k => $imageType)
        {
            if (!ImageManager::resize
            (
             $sourceFile['tmp_name'],
            _PS_IMG_DIR_.'p/'.$id_image.'/'.$id_image.'-'.stripslashes($imageType['name']).'.jpg',
            $imageType['width'],
            $imageType['height']
            )
            ) echo "Chyba IMG ".$file."<br />";
        }
}

after that import i have apropriate values in database tables, but in FO and although BO I cannot seen images, although in BO I see number of images for product, but images are not display. Where is problem in my function?

Link to comment
Share on other sites

×
×
  • Create New...