Jump to content

fail to properly add cover image to a product using api


Recommended Posts

When I try to add a cover image using API to a product, the image fails to load.

the reason is that my browser try to load 

http://prestashop.ufk:8080/7410-small_default/.jpg

 

and the url is supposed to be

http://prestashop.ufk:8080/7410-small_default/<MAYBE IMAGE TAG>.jpg

 

anything in the <MAYBE IMAGER TAG> is ignored by the .htaccess but is required to have at least one character for

the regular expression to work and to forward me to the proper image.

i though i was missing legend but that's not it.

this is how I add an image to a product:

 

require_once _PS_ADMIN_CONTROLLER_DIR_ . 'AdminImportController.php';

class TuxInImage extends AdminImportControllerCore
{

    public static function addProductImage($productId, $imgUrl, $legend,$isCover=false,$regenerate = true)
    {
        $img = new Image();
        $img->id_product = $productId;
        $img->cover=$isCover;
        $img->legend=$legend;
        $img->add();
        $imageId = $img->id;

        self::copyImg($productId, $imageId, $imgUrl, 'products', $regenerate);
    }
}

 

what am I missing ?

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