Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: Can't get product primary image  (Read 4573 times)

Offline Bard00k

  • Newbie
  • *
  • Posts: 5
  • Karma: +2/-0
    • View Profile
Can't get product primary image
« 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?

Offline Bard00k

  • Newbie
  • *
  • Posts: 5
  • Karma: +2/-0
    • View Profile
Re: Can't get product primary image
« Reply #1 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);

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5774
  • Karma: +274/-2
    • View Profile
Re: Can't get product primary image
« Reply #2 on: July 21, 2016, 01:30:25 AM »

 

Powered by SMFPacks Social Login Mod