Back to PhocacartImageAdditional class

Method getImagesByProductId

public static
getImagesByProductId
(mixed $productId, mixed $return = 0)

Method getImagesByProductId - Source code

public static function getImagesByProductId($productId, $return = 0)
{
    $db = Factory::getDBO();
    $query = 'SELECT a.id, a.image';
    $query .= ' FROM #__phocacart_product_images AS a' . ' WHERE a.product_id = ' . (int) $productId . ' ORDER BY a.ordering';
    $db->setQuery($query);
    if ($return == 0) {
        return $db->loadObjectList();
    } else {
        if ($return == 1) {
            return $db->loadAssocList();
        } else {
            $images = $db->loadAssocList();
            $imagesSubform = array();
            $i = 0;
            if (!empty($images)) {
                foreach ($images as $k => $v) {
                    $imagesSubform['additional_images' . $i]['id'] = (string) $v['id'];
                    $imagesSubform['additional_images' . $i]['image'] = (string) $v['image'];
                    $i++;
                }
            }
            return $imagesSubform;
        }
    }
    return false;
}