Jump to content

CSV import Image is not getting populate (? mark image coming)


bhaskey

Recommended Posts

Hi,

I am using PS 1.6.0.9. I have trying to upload image through csv import but no luck.

When i upload a product using csv import picture is not getting uploaded and the ? mark image is showing on the product.

Please note:

  • I tried every possible way which are suggested in many previuos posts and discussions in PS forum.
  • I am giving full-url (eg. http://mystore.com/folder/image.jpg )
  • Both the directories have permission set 777. (By both i mean: where my images are and prestashop's img folder where images get uploded).
  • I tried with giving /folder/image.jpg , where /folder is in my root directory.
  • My image size is not more than 20kb, i am trying to upload 1 image for a product.

 

I am able to do it in my local installation. So i thought, there might be permission problem, but as i mentioned both the directories have CHMOD set to 777.

Please some help.

 

Thanks in advance.

bhaskey (Je Suis Charlie)

Link to comment
Share on other sites

Indeed it might be getting stuck with permissions somehow. Are you able to upload them manually? Are source images sitting on the same server as prestashop? THe absolute url part is the best way to go in any case, with the full url. Can you check if the source folder is accessible via direct url? Like if you try displaying one of the images directly on the browser

Link to comment
Share on other sites

hi nemo,

thanks for quick reply.

 

yes i am able to upload them manully from BO.

source images are on same server in root directory. i also tried from creating a folder in img folder and then do it by giving absoluet url.

source folder, even image is accessible from browser by giving the source url which i using in csv.

 

Please help what might be other cause, and how could it be resolved.

 

................

thanks again

bhaskey (Je Suis Charlie)

Link to comment
Share on other sites

hm, at this point the method used by the AdminImportController simply doesn't work. Let's try debugging a bit. Open that file up and search for the CopyImg method. Use a simple 1 product csv file as test. There are multiple returns in that method, try writing this

 

die('test, I got here');

 

Before each of them. When it doesn't return is where the error is. Of course the process will be broken so test with a fixed product id or the db might screw up just a little bit

Link to comment
Share on other sites

Hey nemo,

 

i did as you said, my CopyImg function looks like this:

protected static function copyImg($id_entity, $id_image = null, $url, $entity = 'products', $regenerate = true)
	{
		$tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import');
		$watermark_types = explode(',', Configuration::get('WATERMARK_TYPES'));

		switch ($entity)
		{
			default:
			case 'products':
				$image_obj = new Image($id_image);
				$path = $image_obj->getPathForCreation();
			break;
			case 'categories':
				$path = _PS_CAT_IMG_DIR_.(int)$id_entity;
			break;
			case 'manufacturers':
				$path = _PS_MANU_IMG_DIR_.(int)$id_entity;
			break;
			case 'suppliers':
				$path = _PS_SUPP_IMG_DIR_.(int)$id_entity;
			break;
		}
		$url = str_replace(' ', '%20', trim($url));

		// Evaluate the memory required to resize the image: if it's too much, you can't resize it.
		if (!ImageManager::checkImageMemoryLimit($url))
			die('test, I got here1');
			//return false;

		// 'file_exists' doesn't work on distant file, and getimagesize makes the import slower.
		// Just hide the warning, the processing will be the same.
		if (Tools::copy($url, $tmpfile))
		{
			ImageManager::resize($tmpfile, $path.'.jpg');
			$images_types = ImageType::getImagesTypes($entity);

			if ($regenerate)
				foreach ($images_types as $image_type)
				{
					ImageManager::resize($tmpfile, $path.'-'.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));
				}
		}
		else
		{
			unlink($tmpfile);
			die('test, I got here2');
			return false;
		}
		unlink($tmpfile);
		die('test, I got here3');
		return true;
	}

As you can see, i put three die statements, at line: 1019, 1040 & 1044.

When i csv import, my webpage returns "test, I got here3", means third one, and photo is also getting uploaded.

 

As long as i understood by this is, image is uploaded, and there is just one line(return true) after "die('test, I got here3')". So, is return true statement deleting the uploaded image or what? Please help i am clueless here.

 

Also can this process affect available quantity of other products?? (i guess it did)....that's strange  :unsure: 

Link to comment
Share on other sites

Also this added these categories:

  • http:
  • mysite.com
  • directory
  • img.jpg

URL of the image which i was testing with was http:/mysite.com/directory/img.jpg.

Also one more effect from this:

On some products it's showing that the product is available in different option in product-list, on product page they are just fine, even in BO there is no other options for those products. I guess i need to delete them and create again.

I hope it didn't screwed anything else. (Pray for me :()

 

PS: nemo1, i am not blaming you man! as you already mentioned that it might screw up my db a little.

Thanks for your help.

Edited by bhaskey (see edit history)
Link to comment
Share on other sites

Well it shouldn't affect available quantities, since killing the script could have only affected 1 row. Strange. In any case, the image is getting uploaded, that die() running means it's just getting rid of the temporary file that was created. I'm a bit confused at this point, so try getting rid of that die and replace it with a var_dump('here3');

If it's supposed to fail elsewhere it will die to either of the other 2

  • Like 1
Link to comment
Share on other sites

Hi nemo,

 

I replaced all the die statements with var_dump, (i was little afraid of'em...they created mess earlier)...no help.

but replacing just the 3rd die statement with var_dump solved my problem, and image is getting populated. Of course if it would have failed elsewhere it would have died on either of the other 2.

 

For now i am testing with just one product, i hope it will work fine in bulk.

 

Thanks a lot for helping me out.. you have saved a lot of manual effort.

Link to comment
Share on other sites

×
×
  • Create New...