News:

AbanteCart v1.4.2 is released.

Main Menu
support

Can't get product primary image

Started by Bard00k, July 18, 2016, 10:14:55 PM

Previous topic - Next topic

Bard00k

I'm trying to get the primary image URL of a product.
I tried the following code:

$resource = new AResource('image');
$sites = $sizes = array('main'  => array('width'  => 400, 'height' => 400));
$images = $resource->getResourceAllObjects('products', $product['product_id'], null, 1);

But $images is just an empty array.

Any ideas? Or maybe there's a more simple way to get product main image URL?

Bard00k

Reply to self, this work:

$sizes = array('main'  => array('width'  => $this->baseObject->config->get('config_image_popup_width'),
              'height' => $this->baseObject->config->get('config_image_popup_height')),
              'thumb' => array('width'  => $this->baseObject->config->get('config_image_thumb_width'),
              'height' => $this->baseObject->config->get('config_image_thumb_height')));
         $main_image = $resource->getResourceAllObjects('products', $product_id, $sizes, 1, false);

Basara


Forum Rules Code of conduct
AbanteCart.com 2010 -