diff --git a/dfTools.class.php b/dfTools.class.php index 7b105a9..4cd9292 100644 --- a/dfTools.class.php +++ b/dfTools.class.php @@ -246,6 +246,38 @@ public static function getAttributeKeysForShopAndLang($id_shop, $id_lang){ return $names; } + + /** + * Returns the features of a product + * @param int Shop ID. + * @param int Language ID. + * @return array of rows (assoc arrays). + */ + public static function getVariationImg($id_product, $id_product_attribute){ + $sql = + "select i.id_image + from + ( + select pa.id_product, pa.id_product_attribute,paic.id_attribute,min(i.position) as posicion + from ps_product_attribute pa + inner join ps_product_attribute_image pai + on pai.id_product_attribute = pa.id_product_attribute + inner join ps_product_attribute_combination paic + on pai.id_product_attribute = paic.id_product_attribute + inner join ps_image i + on pai.id_image = i.id_image + where pa.id_product = $id_product and pa.id_product_attribute = $id_product_attribute + group by pa.id_product, pa.id_product_attribute,paic.id_attribute + ) as P + inner join ps_image i + on i.id_product = P.id_product and i.position = P.posicion"; + $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); + + return $result[0]['id_image']; + + } + + /** * Returns the features of a product * @param int Product ID. diff --git a/dist/doofinder-p1.5-latest.zip b/dist/doofinder-p1.5-latest.zip index c1c7d99..02d27a1 100644 Binary files a/dist/doofinder-p1.5-latest.zip and b/dist/doofinder-p1.5-latest.zip differ diff --git a/doofinder.php b/doofinder.php index 07f65b2..22a7af8 100644 --- a/doofinder.php +++ b/doofinder.php @@ -43,7 +43,7 @@ class Doofinder extends Module const GS_SHORT_DESCRIPTION = 1; const GS_LONG_DESCRIPTION = 2; - const VERSION = "2.0.20"; + const VERSION = "2.0.21"; const YES = 1; const NO = 0; diff --git a/feed.php b/feed.php index 34dd263..e9bf0bd 100755 --- a/feed.php +++ b/feed.php @@ -214,10 +214,12 @@ function slugify($text) if($cfg_product_variations && isset($row['id_product_attribute']) and intval($row['id_product_attribute']) > 0){ $cover = Product::getCover($row['id_product_attribute']); - if($cover){ + $id_image = dfTools::getVariationImg($row['id_product'], $row['id_product_attribute']); + + if(isset($id_image)){ $image_link = dfTools::cleanURL(dfTools::getImageLink( $row['id_product_attribute'], - $cover['id_image'], + $id_image, $row['link_rewrite'], $cfg_image_size)); } diff --git a/package.json b/package.json index aa11876..6a53bdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "doofinder-for-prestashop", - "version": "2.0.20", + "version": "2.0.21", "devDependencies": { "grunt": "^0.4.5", "grunt-contrib-clean": "^0.5.0",