From ffd712312da0fdad349bcf157763f215e0515538 Mon Sep 17 00:00:00 2001 From: ha99y Date: Wed, 28 Aug 2013 00:27:52 -0700 Subject: [PATCH] Add new argument to function getImages 1st: The function will return the product attribute id's with the list. 2nd: If product attribute id is passed to the function it will return only the image id of the given attribute. --- classes/Image.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/Image.php b/classes/Image.php index f2b749bf1..5050f98c9 100644 --- a/classes/Image.php +++ b/classes/Image.php @@ -120,15 +120,19 @@ class ImageCore extends ObjectModel * * @param integer $id_lang Language ID * @param integer $id_product Product ID + * @param integer $id_product_attribute Product Attribute ID * @return array Images */ - public static function getImages($id_lang, $id_product) + public static function getImages($id_lang, $id_product, $id_product_attribute = NULL) { + $attribute_filter = ($id_product_attribute ? ' AND ai.`id_product_attribute` = '.(int)$id_product_attribute : ''); + return Db::getInstance()->executeS(' SELECT * FROM `'._DB_PREFIX_.'image` i LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image`) - WHERE i.`id_product` = '.(int)$id_product.' AND il.`id_lang` = '.(int)$id_lang.' + LEFT JOIN `'._DB_PREFIX_.'product_attribute_image` ai ON (i.`id_image` = ai.`id_image`) + WHERE i.`id_product` = '.(int)$id_product.' AND il.`id_lang` = '.(int)$id_lang . $attribute_filter.' ORDER BY i.`position` ASC'); }