jmstyle008 Posted August 19, 2013 Share Posted August 19, 2013 Hi I created a file to import all my product images from a directory and assigning them accordingly. The problem I've had is that in my DB my cover is set to 1 as its supposed to be while adding an image as the image cover. When i go to my front end and search for this product, i can see the image in the category list page but once i click on the product detail i don't get an image. I get the default Image. When i search for my product in the back end, i see the image and i notice that the cover icon is not set, i have to click on it and save in order to fix this issue. does any one else have an issue like this? The qureies i have are... $sql = 'INSERT INTO image (id_product, position, cover) values("' . $productId . '","' . $position . '","' . $cover . '")'; The following one is according to the id languages $sql = 'INSERT INTO image_lang (id_image, id_lang) values("' . $idImage . '","' . $langId . '")'; for each store i have $sql = 'INSERT INTO image_shop (id_image, id_shop,cover) values("' . $idImage . '","' . $idShop . '", "' . $cover . '")'; Link to comment Share on other sites More sharing options...
PascalVG Posted August 21, 2013 Share Posted August 21, 2013 You said that in the database the cover is correctly set to 1? If so, it's probably a cache problem: First try this: Clear your browser cache and check again. Maybe you also have to reload the page with CTRL-F5 (windows)/Command-R (Mac) If that doesn't do the trick, try this: Temporarily turn off cache in Advanced Parameters->Performance and clear your browser cache once more. See if that helps. Pascal Link to comment Share on other sites More sharing options...
jmstyle008 Posted August 21, 2013 Author Share Posted August 21, 2013 There was a bug in my query. The massive image upload file is working. Thanks!! Link to comment Share on other sites More sharing options...
PascalVG Posted August 22, 2013 Share Posted August 22, 2013 Hi JM, Glad you found the culprit! I'll mark the topic as solved. Would you mind to share the corrected SQL query, for educational purpose? :-) Thanks, pascal 1 Link to comment Share on other sites More sharing options...
GOKULAN R Posted October 6, 2014 Share Posted October 6, 2014 $url='img/10.jpg';( this is your image both) $image = new Image();$image->id_product = $themeid;$image->id_image=$themeid;$image->position = Image::getHighestPosition($id_product) + 1;$image->cover = true; // or false;if (($image->validateFields(false, true)) === true &&($image->validateFieldsLang(false, true)) === true && $image->add()){ $image->associateTo($shops); if (!AdminImportController::copyImg($id_product, $image->id, $url, 'products', false)) { echo"img1234"; $image->delete(); }} Link to comment Share on other sites More sharing options...
ac-angel Posted September 26, 2019 Share Posted September 26, 2019 This code is valid in prestashop 1.7.6 $id_product = 914; $url='http://domain.com/img/logo.jpg'; $image = new Image(); $image->id_product = $id_product; $image->position = 1; $image->cover = true; // or false; if (($image->validateFields(false, true)) === true && ($image->validateFieldsLang(false, true)) === true && $image->add()) { if (AdminImportController::copyImg($id_product, $image->id, $url, 'products', false)) { }else{ echo "fallido"; $image->delete(); } } Link to comment Share on other sites More sharing options...
neuhs Posted November 4, 2020 Share Posted November 4, 2020 Hi @ac-angel, will your code works if $url is an external link? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now