// MERGE with 1.4 r7770

This commit is contained in:
rMalie
2011-07-28 09:20:57 +00:00
parent 60b07cacb9
commit c17e7c236d
968 changed files with 26082 additions and 3937 deletions
+35 -16
View File
@@ -65,14 +65,14 @@ class SpecificPriceCore extends ObjectModel
return $fields;
}
static public function getByProductId($id_product)
public static function getByProductId($id_product)
{
return Db::getInstance()->ExecuteS('
SELECT * FROM `'._DB_PREFIX_.'specific_price` WHERE `id_product` = '.(int)($id_product)
);
}
static public function getIdsByProductId($id_product)
public static function getIdsByProductId($id_product)
{
return Db::getInstance()->ExecuteS('
SELECT `id_specific_price` FROM `'._DB_PREFIX_.'specific_price` WHERE `id_product` = '.(int)$id_product.'
@@ -112,7 +112,7 @@ class SpecificPriceCore extends ObjectModel
return preg_split('/;/', $priority);
}
static public function getSpecificPrice($id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity)
public static function getSpecificPrice($id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity)
{
/*
** The date is not taken into account for the cache, but this is for the better because it keeps the consistency for the whole script.
@@ -132,13 +132,18 @@ class SpecificPriceCore extends ObjectModel
AND `id_country` IN (0, '.(int)$id_country.')
AND `id_group` IN (0, '.(int)$id_group.')
AND `from_quantity` <= '.(int)$quantity.'
AND (`from` = \'0000-00-00 00:00:00\' OR (\''.$now.'\' >= `from` AND \''.$now.'\' <= `to`))
AND
(
(`from` = \'0000-00-00 00:00:00\' OR \''.$now.'\' >= `from`)
AND
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
)
ORDER BY `score` DESC, `from_quantity` DESC');
}
return self::$_specificPriceCache[$key];
}
static public function setPriorities($priorities)
public static function setPriorities($priorities)
{
$value = '';
foreach ($priorities as $priority)
@@ -156,9 +161,8 @@ class SpecificPriceCore extends ObjectModel
');
}
static public function setSpecificPriority($id_product, $priorities)
public static function setSpecificPriority($id_product, $priorities)
{
$fields = '';
$value = '';
foreach ($priorities as $priority)
$value .= pSQL($priority).';';
@@ -170,7 +174,7 @@ class SpecificPriceCore extends ObjectModel
');
}
static public function getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group)
public static function getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group)
{
$now = date('Y-m-d H:i:s');
$res = Db::getInstance()->ExecuteS('
@@ -181,8 +185,13 @@ class SpecificPriceCore extends ObjectModel
`id_shop` IN(0, '.(int)($id_shop).') AND
`id_currency` IN(0, '.(int)($id_currency).') AND
`id_country` IN(0, '.(int)($id_country).') AND
`id_group` IN(0, '.(int)($id_group).') AND
(`from` = \'0000-00-00 00:00:00\' OR (\''.$now.'\' >= `from` AND \''.$now.'\' <= `to`))
`id_group` IN(0, '.(int)($id_group).')
AND
(
(`from` = \'0000-00-00 00:00:00\' OR \''.$now.'\' >= `from`)
AND
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
)
ORDER BY `score` DESC, `from_quantity` DESC
');
@@ -203,7 +212,7 @@ class SpecificPriceCore extends ObjectModel
return $targeted_prices;
}
static public function getQuantityDiscount($id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity)
public static function getQuantityDiscount($id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity)
{
$now = date('Y-m-d H:i:s');
return Db::getInstance()->getRow('
@@ -215,13 +224,18 @@ class SpecificPriceCore extends ObjectModel
`id_currency` IN(0, '.(int)($id_currency).') AND
`id_country` IN(0, '.(int)($id_country).') AND
`id_group` IN(0, '.(int)($id_group).') AND
`from_quantity` >= '.(int)($quantity).' AND
(`from` = \'0000-00-00 00:00:00\' OR (\''.$now.'\' >= `from` AND \''.$now.'\' <= `to`))
`from_quantity` >= '.(int)($quantity).'
AND
(
(`from` = \'0000-00-00 00:00:00\' OR \''.$now.'\' >= `from`)
AND
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
)
ORDER BY `score` DESC, `from_quantity` DESC
');
}
static public function getProductIdByDate($id_shop, $id_currency, $id_country, $id_group, $beginning, $ending)
public static function getProductIdByDate($id_shop, $id_currency, $id_country, $id_group, $beginning, $ending)
{
$resource = Db::getInstance()->ExecuteS('
SELECT `id_product`
@@ -231,7 +245,12 @@ class SpecificPriceCore extends ObjectModel
`id_country` IN(0, '.(int)($id_country).') AND
`id_group` IN(0, '.(int)($id_group).') AND
`from_quantity` = 1 AND
(`from` = \'0000-00-00 00:00:00\' OR (\''.$beginning.'\' >= `from` AND \''.$ending.'\' <= `to`)) AND
(
(`from` = \'0000-00-00 00:00:00\' OR \''.$beginning.'\' >= `from`)
AND
(`to` = \'0000-00-00 00:00:00\' OR \''.$ending.'\' <= `to`)
)
AND
`reduction` > 0
', false);
$ids_product = array();
@@ -240,7 +259,7 @@ class SpecificPriceCore extends ObjectModel
return $ids_product;
}
static public function deleteByProductId($id_product)
public static function deleteByProductId($id_product)
{
return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'specific_price` WHERE `id_product` = '.(int)($id_product));
}