Jump to content

Product Mini image from another product?


ScottC613

Recommended Posts

Hi there.  I'm hoping someone else has had a similar experience and knows how to permanently solve this issue or can give me some details on how the product mini images are assigned.

prestashop version 1.7.7.0

all images on the front end as well as the images inside the product listings on the back end are ok.

the mini images in the catalogue listing in the back end seem to not be the image of the actual product but of one of the other products instead as if the assignment of the mini image files are being swapped with other products.  In the attached screen grab, note that the product mini image is for a different existing product and does not match the image in the screen grab of the product photo from inside the product listing.

i can temporarily correct the issue by going to the folder /img/tmp/ and deleting all of the Product_mini_X.jpg files and allowing prestashop to regenerate them however over time it eventually ends up with incorrect images again.  Any idea what could be causing this or where something might be reading the wrong data in order to make the incorrect image assignments?

correct image.JPG

wrong image.JPG

Link to comment
Share on other sites

9 hours ago, irder shopping said:

maybe you can view the image url and delete the tmp image file ,and it will regenrate a new right one.

when i delete them all it seems to regenerate and then eventually get them mixed up.  i assume the same would happen if i just deleted specific files.  There must be a table or something where it lists what mini images to load for each catalogue item.  If it goes by product ID or something maybe something is off or corrupt but then i dont understand why it would regenerate them properly if i deleted the cached ones.  you'd think it would make the same mess immediately when they were regenerated but thats not what happens.  I wonder if something in the caching system itself could be the problem.

Link to comment
Share on other sites

Hi.
Do you use a script or module to update products?
Product thumbnails are stored in the tmp folder, with the product id in the name.
Other images that are in the img/p/ folder are stored in the database in the ps_image table.
The thumbnail takes id_image and id_product from this table, where cover = 1 is written in the table.
So Prestashop will call Product::getCover function.

Link to comment
Share on other sites

Yes, cache is problem.

ImageManager.php

/**

* Generate a cached thumbnail for object lists (eg. carrier, order statuses...etc).

*

* @param string $image Real image filename

* @param string $cacheImage Cached filename

* @param int $size Desired size

* @param string $imageType Image type

* @param bool $disableCache When turned on a timestamp will be added to the image URI to disable the HTTP cache

* @param bool $regenerate When turned on and the file already exist, the file will be regenerated

*

* @return string|bool

*/

Link to comment
Share on other sites

8 hours ago, irder shopping said:

the img path is 

../img/tmp/product_mini_15_1.jpg?time=1673145264

15 is the product id

i am not sure the timestamp is added by me or it's original code,

if yours don't have,you can try add a timestamp , it will alway load the new image

i checked the image link and it seems to have the time stamp already.   

product_mini_399.jpg?time=1673175670

 

Link to comment
Share on other sites

8 hours ago, prestashopfree.com said:

Hi.
Do you use a script or module to update products?
Product thumbnails are stored in the tmp folder, with the product id in the name.
Other images that are in the img/p/ folder are stored in the database in the ps_image table.
The thumbnail takes id_image and id_product from this table, where cover = 1 is written in the table.
So Prestashop will call Product::getCover function.

 

Initially when the products were added they were imported through store manager.  It made a mess of the images initially but i then deleted all the images and reuploaded them manually to correct the issue.  The only other modules that i can think of that might touch images would be an seo images module but the problem predates that being installed, and a speed optimization module named Superspeed which can do image compression.

 

I had a look at the PS_image table as well as the files in the images folder and found some odd results

Ps_images table:

Noted observation - some of the table entries the have various image position numbers but cover set as null is this expected and normal or should this simply be a 1 or 0 value only?

located the product ID for one of the effected products by a select query on the product ID

SELECT * FROM `ps_image` WHERE `id_product`='476'

the result showed the Image ID was 399 with position and cover set as 1

 

/img/p folder

Browsed to /img/p/3/9/9  on the server.  Image storage seems to be broken down that each character of the image id is a subfolder.

I opened and viewed each image stored in the folder to see if any of these were the wrong image however they all appeared to be the correct images for the product.

 

Image URL

the url for the mini image seems to have the correct image id number (399) as well as the timestamp however the image content is a different product.

product_mini_399.jpg?time=1673175670

 

/img/tmp folder

Browsed to the above folder and located the product_mini_399.jpg file and opened it and the image seems the be the wrong product.

 

 

 

 

Link to comment
Share on other sites

3 hours ago, prestashopfree.com said:

Thank you.

And product_mini_476.jpg ?

This should be a mini image of the 476 product.

i just went and looked in /img/tmp and yes it seems that the product_mini_476 is the mini image that looks correct for product 476.  There is also a 476_0 which seems to be a duplicate

I also looked in the /img/p/4/7/6/ folder and the images stored there are for a completely different product.

 

very curious how you managed to guess this.

Is the image ID in ps_images table supposed to match the product ID?  

is this an issue of the naming function of the image generator naming the product_mini files incorrectly or a mistake in how the code for the back office sets the image url for the mini images?

 

 

Link to comment
Share on other sites

So in effect the product mini should have the same number as the product ID.

This makes sense as when i looked at the product mini photo with the same product ID it seemed correct.  I wonder how the function that writes the image url in the catalogue page is choosing a product mini that does not match the product ID?  Could it be somehow reading the id_image field by mistake somehow and then writing the image url onto the page when it is created?  That might explain why the product mini url that is being set matches the image id from ps_images instead of the actual product id.

Link to comment
Share on other sites

  • 1 year later...

Hi,
I also have a similar problem on my backoffice, the thumbnail of the products that have no image is incorrect (it shows the image of an old product that has been deleted instead of the default "no image").
I tried to delete the image on the tmp, but after the refresh it is regenerated in the same way.
Cache cleared and regenerated.
The strange thing is the image name that is generated and linked: product_mini_.jpg (without the product ID).
What could I do to solve the problem?
It is quite annoying to find an untrue image on the back office.
Thank you.

Schermata da 2024-01-15 11-31-44.png

Link to comment
Share on other sites

Thanks for the reply, but it's not a solution for my case.
The product images are automatically downloaded from Icecat, but when the products are not present in the Icecat DB no image is downloaded, and Prestashop always offers me the image of a product that no longer exists instead of the usual default image " No Image".
The default images are present on /img/p/it-default*.jpg but are not used.
How could I solve it?
Thank you.

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

Hi.

Probably like this. Preestashop displays images according to what it has stored in the database. So if the product has image ids stored in the database, it displays them. Give us a screenshot of the product detail page from the administration. If you have a module that downloads images externally, there is an error in it. So far you are giving us piecemeal information here.

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