diff --git a/dfTools.class.php b/dfTools.class.php index 5215875..3678751 100644 --- a/dfTools.class.php +++ b/dfTools.class.php @@ -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 @@ -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, @@ -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); } diff --git a/doofinder.php b/doofinder.php index 4780a15..8d823f9 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 = "1.5.0"; + const VERSION = "1.5.1"; const YES = 1; const NO = 0; diff --git a/feed.php b/feed.php index 24b6b6a..b267008 100755 --- a/feed.php +++ b/feed.php @@ -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'); diff --git a/package.json b/package.json index fb0dd4f..e74fc99 100644 --- a/package.json +++ b/package.json @@ -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",