Jump to content

Products with no product image, not displaying the 404.gif image in Prestashop 1.5.


Recommended Posts

Hi there,

 

Is anyone else having this issue?

 

I recently upgraded to Prestashop 1.5. Not all of the products have images set for them...so those particular products should be displaying the 404.gif but it's just not finding it.

 

 

On prestashop 1.4 - if you checked the url of a 404'd image, you'd see something like this:

<img src="http://mydomain.com/1492-home/ac8-volt.jpg">'>http://mydomain.com/1492-home/ac8-volt.jpg"> and if you tried to open that url:

http://mydomain.com/1492-home/ac8-volt.jpg -> it redirected to http://mydomain.com/img/404.gif

Which worked great -> all missing images showed the 404 image instead.

 

Now on 1.5 - if you click the same url, instead of redirecting to 404.gif.. it takes me to :

http://mydomain.com/page-not-found -> so thumbnails etc are not getting the 404.gif for products without images. (see image below)

 

post-299242-0-98643400-1348502411_thumb.jpg

 

Any idea what's going wrong? :blink:

 

I did check the image directory to see if the 404.gif file is still there...and it is...

 

Also tried generating thumbnails...didn't help.

 

 

These are the errors I'm getting when I inspect element and look at the console...(if you need my site details, I can PM them to you...)

 

The blurred out section under the 5th column is the domain of my site...

The blurred out section in the first column is the name of the folder the site lives in on my server (I have other sites on the server...)

 

See image:

post-299242-0-89796400-1348503774_thumb.jpg

 

The two products referred to in the error are both products that should be displaying the 404.gif as they do not have images set for them.

 

 

 

Thanks!

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

Well if anyone is interested...I fixed this problem.

 

In Prestashop 1.4. if you added a product but didn't upload a picture for it, prestashop would generate images for those products. This is the image it would use:

 

post-299242-0-06253200-1362218241.jpg

 

Which is correct.

 

Then when you upgrade to 1.5, the products don't display the above image, it will give you a missing image icon like this:

 

post-299242-0-98643400-1348502411.jpg

 

First thing I noticed is this:

 

I switched off friendly urls, then inspected the missing images with firebug. I found that they were trying to retrieve images from the folder root/img/p when I looked in the folder, many of those images didn't even exist. I tried to generate them from the back end but it wasn't doing anything. So I created them manually and placed them in the folder (I attached the images in a zip file...you can copy them into the root/img/p folder if they aren't there and if you need them).

 

NOTE: It seems that prestashop was not generating these images for me and when I try regenerating thumbnails, the images I created disappear again so I'd have to copy them back again after regenerating thumbs. Also depending on your theme/template files, you may not even require the same images...so examine things carefully.

 

After copying those images over, it only fixed SOME of the products.

 

There were still many that were trying to retrieve the image from a directory in which the image just simply did not exist (again, you can check what directory it is pointing at by turning off friendly urls and inspecting the element with firebug - it was usually looking in a directory that looked something like this: www.myshop.com/img/p/9/1/0/8/9108.jpg)...so after examining the database, I discovered that I had to remove any references to missing images from the database in the table ps_image...

 

I logged in to phpmyadmin, and navigated to the table "ps_image", looked for the rows that matched the product id of the affected product and deleted the record from the table. The products then started to use the correct images. (Don't mess with sql unless you have a backup of the tables and you're very comfortable working with sql/database entries...any mistakes will cause damage to your site.)

 

If you have a ton of products to fix, it would take FOREVER to delete one record at a time...so I had to get a bit creative and do it programmatically.

 

I first regenerated the images in the back office...(preferences>images>regenerate thumbnails>select products)...and it gave me errors which told me which images were missing...

 

The messages looks like this:

Original image is missing or empty (/home/myshop/public_html/img/p/9/1/0/8/9108.jpg)

 

Original image is missing or empty (/home/myshop/public_html/img/p/9/1/0/7/9107.jpg)

Original image is missing or empty (/home/myshop/public_html/img/p/9/1/0/8/9108.jpg)

 

(I had 9411 missing images)

 

 

 

So I copied all the error messages into notepad++ and used regex and macros to clean up the error messages so that I could isolate just the product id number...the number just before the .jpg extension...so in this example:

 

Original image is missing or empty (/home/myshop/public_html/img/p/9/1/0/8/9108.jpg)

 

I wanted to isolate the number: 9108

 

Then I used more macros in notepad++ to create an sql statement like this:

 

DELETE FROM ps_image WHERE id_product IN ('2', '4', '10', '11', '14', '15', '16', '17', '18', '19', '23', '24', '25', '26', '30', '32', '36', '37', '45', '53', '55', '62', '63', '75', '76', '78', '79', '80', '81', '83', '92', '93', '96', '98', '103', '104', '114', '115', '116', '117', '119', '129', '132', '141', '160', '161', '163', '165', '175', '182', '183', '192', '195', '207', '212', '220', '228', '234', '236', '246', '247', '248', '259', '260', '261', '275', '296', '297', '298', '300', '301', '302', '315', '317', '321', '323', '324', '325', '326', '327', '328', '329', '330', '331', '332', '333', '334', '340', '341', '342', '343', '344', '345', '346', '347');

 

(mine was MUCH MUCH MUCH MUCH longer than the above example which is why I used macros!)

 

Run that statement in phpmyadmin and it will delete all the rubbish data in the table.

 

Then clear cache and refresh your browser and your product image issues should be gone!

 

If it still persists, try regenerating product images but remember: you'd probably have to recopy the the image files from the zip folder attached to root/img/p...

 

 

Hope this is helpful to someone... :unsure::rolleyes:

img-p.zip

Edited by Arkadia (see edit history)
  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...