// Merge -> revision 7875

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7877 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-08-03 16:16:49 +00:00
parent 6f08bcb12e
commit f2b5ee338b
38 changed files with 320 additions and 85 deletions
+19 -4
View File
@@ -27,6 +27,15 @@
class CarrierCore extends ObjectModel
{
/**
* getCarriers method filter
*/
const PS_CARRIERS_ONLY = 1;
const CARRIERS_MODULE = 2;
const CARRIERS_MODULE_NEED_RANGE = 3;
const PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE = 4;
const ALL_CARRIERS = 5;
const SHIPPING_METHOD_DEFAULT = 0;
const SHIPPING_METHOD_WEIGHT = 1;
const SHIPPING_METHOD_PRICE = 2;
@@ -340,7 +349,7 @@ class CarrierCore extends ObjectModel
* @param boolean $active Returns only active carriers when true
* @return array Carriers
*/
public static function getCarriers($id_lang, $active = false, $delete = false, $id_zone = false, $ids_group = NULL, $modules_filters = 1)
public static function getCarriers($id_lang, $active = false, $delete = false, $id_zone = false, $ids_group = NULL, $modules_filters = self::PS_CARRIERS_ONLY)
{
if (!Validate::isBool($active))
die(Tools::displayError());
@@ -351,7 +360,7 @@ class CarrierCore extends ObjectModel
$ids .= (int)($id).', ';
$ids = rtrim($ids, ', ');
if ($ids == '')
return (array());
return array();
}
$sql = 'SELECT c.*, cl.delay
@@ -430,6 +439,12 @@ class CarrierCore extends ObjectModel
return $countries;
}
/**
*
* @param int $id_zone
* @param Array $groups group of the customer
* @return Array
*/
public static function getCarriersForOrder($id_zone, $groups = NULL)
{
$context = Context::getContext();
@@ -441,9 +456,9 @@ class CarrierCore extends ObjectModel
$id_currency = $context->currency->id;
if (is_array($groups) AND !empty($groups))
$result = Carrier::getCarriers($id_lang, true, false, (int)$id_zone, $groups, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
$result = Carrier::getCarriers($id_lang, true, false, (int)$id_zone, $groups, self::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
else
$result = Carrier::getCarriers($id_lang, true, false, (int)$id_zone, array(1), PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
$result = Carrier::getCarriers($id_lang, true, false, (int)$id_zone, array(1), self::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
$resultsArray = array();
foreach ($result AS $k => $row)
+34 -2
View File
@@ -1008,8 +1008,8 @@ class CategoryCore extends ObjectModel
public function getWsNbProductsRecursive()
{
$result = Db::getInstance()->ExecuteS(
'SELECT count(distinct(id_product)) as nb_product_recursive FROM `'._DB_PREFIX_.'category_product`
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT count(distinct(id_product)) as nb_product_recursive FROM `'._DB_PREFIX_.'category_product`
WHERE id_category IN (SELECT id_category
FROM `'._DB_PREFIX_.'category`
WHERE nleft > '.(int)$this->nleft.
@@ -1018,5 +1018,37 @@ class CategoryCore extends ObjectModel
return -1;
return $result[0]['nb_product_recursive'];
}
/**
*
* @param Array $ids_category
* @param int $id_lang
* @return Array
*/
public static function getCategoryInformations($ids_category, $id_lang = null)
{
if ($id_lang === null)
{
global $cookie;
$id_lang = $cookie->id_lang;
}
if (!is_array($ids_category) || !sizeof($ids_category))
return;
$categories = array();
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`, cl.`id_lang`
FROM `'._DB_PREFIX_.'category` c
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`)
WHERE cl.`id_lang` = '.(int)$id_lang.'
AND c.`id_category` IN ('.implode(',', $ids_category).')
');
foreach($results as $category)
$categories[$category['id_category']] = $category;
return $categories;
}
}
+1 -1
View File
@@ -110,7 +110,7 @@ class ConfigurationTestCore
if ($recursive)
{
while (($file = readdir($dh)) !== false)
if (@filetype($dir.$file) == 'dir' AND $file != '.' AND $file != '..')
if (is_dir($dir.$file) AND $file != '.' AND $file != '..')
if (!self::test_dir($dir.$file, true))
return false;
}
+17 -1
View File
@@ -117,7 +117,7 @@ abstract class ObjectModelCore
if ($id_lang != NULL && Validate::isLoadedObject(new Language($id_lang)))
$this->id_lang = $id_lang;
elseif ($id_lang != NULL)
die(Tools::displayError());
$this->id_lang = Configuration::get('PS_LANG_DEFAULT');
if ($id_shop && $this->langMultiShop)
{
@@ -853,4 +853,20 @@ abstract class ObjectModelCore
return false;
return true;
}
/**
* Specify if an ObjectModel is already in database
*
* @param $id_entity entity id
* @return boolean
*/
public static function existsInDatabase($id_entity)
{
$row = Db::getInstance()->getRow('
SELECT `id_'.self::$table.'`
FROM `'._DB_PREFIX_.self::$table.'` e
WHERE e.`id_'.self::$table.'` = '.(int)($id_entity));
return isset($row['id_product']);
}
}
+2 -17
View File
@@ -1567,7 +1567,8 @@ class ProductCore extends ObjectModel
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT cp.`id_category`, cl.`name`, cl.`link_rewrite` FROM `'._DB_PREFIX_.'category_product` cp
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (cp.`id_category` = cl.`id_category`)
WHERE cp.`id_product` = '.(int)$id_product);
WHERE cp.`id_product` = '.(int)$id_product.'
AND cl.`id_lang` = '.(int)$id_lang);
foreach ($row as $val)
$ret[$val['id_category']] = $val;
return $ret;
@@ -3037,22 +3038,6 @@ class ProductCore extends ObjectModel
return true;
}
/**
* Specify if a product is already in database
*
* @param $id_product Product id
* @return boolean
*/
public static function existsInDatabase($id_product)
{
$row = Db::getInstance()->getRow('
SELECT `id_product`
FROM '._DB_PREFIX_.'product p
WHERE p.`id_product` = '.(int)($id_product));
return isset($row['id_product']);
}
public static function idIsOnCategoryId($id_product, $categories)
{
$sql = 'SELECT id_product FROM `'._DB_PREFIX_.'category_product` WHERE `id_product`='.(int)($id_product).' AND `id_category` IN(';
-2
View File
@@ -538,8 +538,6 @@ class ToolsCore
self::deleteDirectory($dirname.$file, true);
elseif (file_exists($dirname.$file))
unlink($dirname.$file);
else
p('Unable to delete '.$dirname.$file);
}
if($delete_self)
rmdir($dirname);