Jump to content

Error when adding product image after deleting rows from ps_image table in Prestashop 1.6


andrw

Recommended Posts

I made a mistake and I need your help. I have a store based on Prestashop 1.6 and I was running out of space on the server so I decided to delete the images of disabled products.

I identified the IDs of disabled products with:

$sql_products = "SELECT id_product FROM ".DB_PREFIX."product WHERE active = 0";

I found out which images are related to these products with:

$sql_images = "SELECT id_image FROM ".DB_PREFIX."image WHERE id_product = ".$id_product;

I deleted the images/directories related to these images as well as the rows from the database with:

$sql_delete_image = "DELETE FROM ".DB_PREFIX."image WHERE id_image = ".$id_image;

Now, sometimes, I encounter an issue when adding an image to a product and I think it might be related to what I did.

Any tips on why this is happening and/or how to solve this problem?

Thank you in advance!

Link to comment
Share on other sites

Hi,
The issue seems to be due to incomplete deletion. If you deleted image files from the server but did not update the corresponding database entries properly, Prestashop may still be trying to access these missing image files when you attempt to add new image

Please refer to the image_shop table as this table enhance functionality to support multi store environments by managing the associations between product images and individual shops and product ID

Also for a detailed look at the issue, when you encounter an issue while adding an image to a product, check for any error messages or warnings displayed by Prestashop(With debug mode enabled). It will help us to more closely look into the issue.

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