Jump to content

Recommended Posts

I'm trying to add programmatically a product image with this code

$id_product = $product->id;
$url = 'http://server.com/img/myproductimage.jpg';
$shops = Shop::getShops(true, null, true);
$image = new Image();
$image->id_product = $id_product;
$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', true))
    {
        $image->delete();
    }
}

But it seems like it doesn't download image. It adds to product, but no image is shown:

https://image.ibb.co/jS4F9d/blank_image_ps.png

What could be wrong with this?

Thanks in advantage.

Share this post


Link to post
Share on other sites
  • 1 year later...

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

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More