willowtree Posted January 13, 2022 Share Posted January 13, 2022 Hello, I have xls files from my suppliers with all of the data needed, apart form the images. My images all follow the format of reference.jpg referencea.jpg referenceb.jpg where reference is the reference number of the item being imported as the reference. what I want to do is upload the images in bulk to the img/tmp folder, and for the import script in prestashop to use the images there. I have tried to add this to the controllers/admin/AdminImportController with no success. Line 2580 (site.com is to hide the actual address) Does anyone have any suggestions? $id_image = []; // CustomCode - add default images to import Process // default upload location is http://site.com/img/tmp/ // $info['product_reference'] $info['image_url'] .= ", http://site.com/img/tmp/{$info['product_reference']}.jpg; http://site.com/img/tmp/{$info['product_reference']}a.jpg; http://site.com/img/tmp/{$info['product_reference']}b.jpg"; // end CustomCode Link to comment Share on other sites More sharing options...
knacky Posted January 15, 2022 Share Posted January 15, 2022 $info['image_url'] = "http://site.com/img/tmp/$info['product_reference'].jpg","http://site.com/img/tmp/$info['product_reference']a.jpg","http://site.com/img/tmp/$info['product_reference']b.jpg"; 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 15, 2022 Share Posted January 15, 2022 Good. Or: $suffix = array('','a','b'); foreach ($suffix as $suff){ if (file_exists(_PS_TMP_IMG_DIR_.$info['product_reference'].$suff.'.jpg')){ $info['image_url'] = _PS_TMP_IMG_DIR_.$info['product_reference'].$suff.'.jpg'; } } 1 Link to comment Share on other sites More sharing options...
willowtree Posted January 16, 2022 Author Share Posted January 16, 2022 neither of these seem to work Link to comment Share on other sites More sharing options...
ps8modules Posted January 16, 2022 Share Posted January 16, 2022 I tested on PS 1.7.8.1 and it works. You're making a mistake somewhere. 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 16, 2022 Share Posted January 16, 2022 What function did you put it in? To the protected function attributeImportOne function? 1 Link to comment Share on other sites More sharing options...
willowtree Posted January 16, 2022 Author Share Posted January 16, 2022 (edited) I have it in controllers/admin/AdminImportController with no success. Line 2580 I believe it is that function Edited January 16, 2022 by willowtree (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted January 16, 2022 Share Posted January 16, 2022 You must edit the protected function productImportOne !! You have not written the exact version of Prestashop. Each version has changes, and line 2580 may not be the same for another version. 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 16, 2022 Share Posted January 16, 2022 1 Link to comment Share on other sites More sharing options...
ps8modules Posted January 16, 2022 Share Posted January 16, 2022 1 Link to comment Share on other sites More sharing options...
willowtree Posted January 16, 2022 Author Share Posted January 16, 2022 (edited) I have moved it to the top of the function and it's still not working, this is PS 1.7.7.8 protected function attributeImportOne($info, $default_language, &$groups, &$attributes, $regenerate, $shop_is_feature_active, $validateOnly = false) { AdminImportController::setDefaultValues($info); //start edit $suffix = array('','a','b'); foreach ($suffix as $suff){ if (file_exists(_PS_TMP_IMG_DIR_.$info['product_reference'].$suff.'.jpg')){ $info['image_url'] = _PS_TMP_IMG_DIR_.$info['product_reference'].$suff.'.jpg'; } } // end edit It was just after the $id_image = []; line Edited January 16, 2022 by willowtree (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted January 16, 2022 Share Posted January 16, 2022 (edited) Do you understand PHP? Edited January 16, 2022 by 4you.software (see edit history) 1 Link to comment Share on other sites More sharing options...
willowtree Posted January 16, 2022 Author Share Posted January 16, 2022 still no success, the code in the image above is different to the original code? Link to comment Share on other sites More sharing options...
ps8modules Posted January 16, 2022 Share Posted January 16, 2022 Why are you giving $info['image_url'] there when I gave you an image with $product-> image[]? The next section reads foreach($product->image .... from $product-> image and not from $info['image_url']. Check it out. I'm leaving with help. 1 Link to comment Share on other sites More sharing options...
willowtree Posted January 16, 2022 Author Share Posted January 16, 2022 I know you are not longer helping, but for for anyone else reading this later, the initial post ner the top of the thread had this which is where the confusion came from.Unfortunately it still doesn't seem to work. Link to comment Share on other sites More sharing options...
knacky Posted January 16, 2022 Share Posted January 16, 2022 You made the confusion by entering line 2580 !! You got a solution for a function that contains line 2580. Then he noticed that you entered the wrong location and gave you the right solution. I also tested this solution in the productImportOne function and it is functional. Writing here that something is not working without an error log is also irresponsible. How can we see what you wrote where? How can we check the error? Turn on debug mode. 1 Link to comment Share on other sites More sharing options...
willowtree Posted January 16, 2022 Author Share Posted January 16, 2022 Sorry for misunderstanding and not spotting that the code in the 2 posts was different. I mentioned line 2580 in the original post, obviously my mistake again. It's fantastic that it is working for you, I'm just sorry I still don't understand what code people are suggesting where. Glad I could help someone else with a solution. what a helpful forum! I'm obviously too stupid to even ask for help here so I guess I'll leave. 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