Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
GetVariationImg
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoslado committed Mar 14, 2016
1 parent 9349ffc commit 7632039
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
32 changes: 32 additions & 0 deletions dfTools.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Binary file modified dist/doofinder-p1.5-latest.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion doofinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 7632039

Please sign in to comment.