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

Commit

Permalink
#1829
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Escribano <[email protected]>
  • Loading branch information
carlosescri committed Sep 8, 2014
1 parent eceefd2 commit b5bf505
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
58 changes: 51 additions & 7 deletions dfTools.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,33 @@ public static function getAvailableCurrencies()
return $currencies;
}

/**
* 1.[5].0.13 | 1.5.[0].5 | 1.5.0.[1]
* 1.[6].0.6 | 1.5.[1].0 | 1.5.0.[5]
*
* @param [type] $min_version [description]
* @return [type] [description]
*/
public static function versionGte($min_version)
{
$version = explode('.', _PS_VERSION_);
$min_version = explode('.', $min_version);

foreach($version as $index => $value)
{
if (intval($value) > intval($min_version[$index]))
{
return true;
}
elseif (intval($value) < intval($min_version[$index]))
{
return false;
}
}

return true;
}


/**
* Returns the products available for a language
Expand All @@ -150,7 +177,7 @@ public static function getAvailableProductsForLanguage($id_lang, $id_shop, $limi
$sql = "
SELECT
ps.id_product,
ps.id_category_default,
__ID_CATEGORY_DEFAULT__,
m.name AS manufacturer,
Expand Down Expand Up @@ -183,24 +210,41 @@ public static function getAvailableProductsForLanguage($id_lang, $id_shop, $limi
LEFT JOIN (_DB_PREFIX_image im INNER JOIN _DB_PREFIX_image_shop ims ON im.id_image = ims.id_image)
ON (p.id_product = im.id_product AND ims.id_shop = _ID_SHOP_ AND _IMS_COVER_)
WHERE
ps.active = 1
AND ps.visibility IN ('search', 'both')
__IS_ACTIVE__
__VISIBILITY__
ORDER BY
p.id_product
";

$mpn_field = dfTools::cfg($id_shop, 'DF_GS_MPN_FIELD', 'reference');

$ps_version_150 = explode('.', _PS_VERSION_);
$ps_version_150 = $ps_version_150[2] == "0";
// MIN: 1.5.0.9
$id_category_default = self::versionGte('1.5.0.9') ? 'ps.id_category_default' : 'p.id_category_default';
// MIN: 1.5.1.0
$ims_cover = self::versionGte('1.5.1.0') ? 'ims.cover = 1' : 'im.cover = 1';
$is_active = self::versionGte('1.5.1.0') ? 'ps.active = 1' : 'p.active = 1';

$ims_cover = $ps_version_150 ? '1 = 1' : 'ims.cover = 1';
if (self::versionGte('1.5.1.0'))
{
$visibility = "AND ps.visibility IN ('search', 'both')";
}
elseif (self::versionGte('1.5.0.9'))
{
$visibility = "AND p.visibility IN ('search', 'both')";
}
else
{
$visibility = "";
}

$sql = self::limitSQL($sql, $limit, $offset);
$sql = self::prepareSQL($sql, array('_ID_LANG_' => $id_lang,
'_ID_SHOP_' => $id_shop,
'__MPN__' => $mpn_field,
'_IMS_COVER_' => $ims_cover));
'_IMS_COVER_' => $ims_cover,
'__ID_CATEGORY_DEFAULT__' => $id_category_default,
'__IS_ACTIVE__' => $is_active,
'__VISIBILITY__' => $visibility));

return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
Expand Down
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 = "1.5.0";
const VERSION = "1.5.1";

const YES = 1;
const NO = 0;
Expand Down
2 changes: 1 addition & 1 deletion feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* - prices: Boolean. Display Prices. Default true.
*/

@set_time_limit(0);
@set_time_limit(3600 * 2);

require_once(dirname(__FILE__) . '/../../config/config.inc.php');
require_once(dirname(__FILE__) . '/../../init.php');
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": "1.5.0",
"version": "1.5.1",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.5.0",
Expand Down

0 comments on commit b5bf505

Please sign in to comment.