Jump to content

import images automatically


willowtree

Recommended Posts

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

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 by willowtree (see edit history)
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

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