AbanteCart Community

AbanteCart Development => Extensions and Add-Ons => Topic started by: Bard00k on July 18, 2016, 10:14:55 PM

Title: Can't get product primary image
Post by: Bard00k on July 18, 2016, 10:14:55 PM
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?
Title: Re: Can't get product primary image
Post by: Bard00k on July 20, 2016, 07:38:58 PM
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);
Title: Re: Can't get product primary image
Post by: Basara on July 21, 2016, 01:30:25 AM
Hello.

Check this doc for developers http://docs.abantecart.com/pages/developer/architecture.html