Optmized the functions and removed non rquired object initialization to reduce stress
This commit is contained in:
@@ -2296,7 +2296,6 @@ class CartCore extends ObjectModel
|
||||
$orderPackage = array();
|
||||
$serviceProducts = array();
|
||||
$objRoomType = new HotelRoomType();
|
||||
$objHtlCartBookingData = new HotelCartBookingData();
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail();
|
||||
foreach ($final_package_list as $id_address => $packages) {
|
||||
|
||||
@@ -931,12 +931,21 @@ class ProductCore extends ObjectModel
|
||||
), 'id_product = '.(int)$id_product);
|
||||
}
|
||||
|
||||
public static function getProductPriceCalculation($id_product) {
|
||||
return Db::getInstance()->getValue(
|
||||
'SELECT product_shop.`price_calculation_method`
|
||||
FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE p.`id_product` = '.(int)$id_product
|
||||
);
|
||||
public static function getProductPriceCalculation($id_product)
|
||||
{
|
||||
$cache_key = 'Product::getProductPriceCalculation'.(int)$id_product;
|
||||
if (!Cache::isStored($cache_key)) {
|
||||
$res = Db::getInstance()->getValue(
|
||||
'SELECT product_shop.`price_calculation_method`
|
||||
FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE p.`id_product` = '.(int)$id_product
|
||||
);
|
||||
Cache::store($cache_key, $res);
|
||||
} else {
|
||||
$res = Cache::retrieve($cache_key);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -975,10 +984,18 @@ class ProductCore extends ObjectModel
|
||||
|
||||
public static function isBookingProduct($id_product)
|
||||
{
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT `booking_product` FROM `'._DB_PREFIX_.'product` p
|
||||
WHERE p.`id_product` = '.(int)$id_product
|
||||
);
|
||||
$cache_key = 'Product::isBookingProduct'.(int)$id_product;
|
||||
if (!Cache::isStored($cache_key)) {
|
||||
$res = Db::getInstance()->getValue('
|
||||
SELECT `booking_product` FROM `'._DB_PREFIX_.'product` p
|
||||
WHERE p.`id_product` = '.(int)$id_product
|
||||
);
|
||||
Cache::store($cache_key, $res);
|
||||
} else {
|
||||
$res = Cache::retrieve($cache_key);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
|
||||
@@ -527,9 +527,17 @@ class HotelBranchInformation extends ObjectModel
|
||||
*/
|
||||
public static function getHotelIdByIdCategory($id_category)
|
||||
{
|
||||
return Db::getInstance()->getValue(
|
||||
'SELECT `id` FROM `'._DB_PREFIX_.'htl_branch_info` WHERE id_category = '.(int)$id_category
|
||||
);
|
||||
$cache_key = 'HotelBranchInformation::getHotelIdByIdCategory'.(int)$id_category;
|
||||
if (!Cache::isStored($cache_key)) {
|
||||
$res = Db::getInstance()->getValue(
|
||||
'SELECT `id` FROM `'._DB_PREFIX_.'htl_branch_info` WHERE id_category = '.(int)$id_category
|
||||
);
|
||||
Cache::store($cache_key, $res);
|
||||
} else {
|
||||
$res = Cache::retrieve($cache_key);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1350,7 +1350,7 @@ class HotelCartBookingData extends ObjectModel
|
||||
* @param [int] $id_group [id_group for which price is need (if available for the passed group)]
|
||||
* @return [array|false] [returns array containg info of the feature plan if foung otherwise returns false]
|
||||
*/
|
||||
public function getProductFeaturePricePlanByDateByPriority(
|
||||
public static function getProductFeaturePricePlanByDateByPriority(
|
||||
$id_product,
|
||||
$date,
|
||||
$id_group,
|
||||
|
||||
@@ -248,12 +248,20 @@ class HotelRoomType extends ObjectModel
|
||||
*/
|
||||
public static function getHotelIdAddressByIdProduct($id_product)
|
||||
{
|
||||
return Db::getInstance()->getValue(
|
||||
'SELECT `id_address` from `'._DB_PREFIX_.'address` a
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt
|
||||
ON (hrt.`id_hotel` = a.`id_hotel`)
|
||||
WHERE hrt.`id_product` = '.(int)$id_product.' AND a.`deleted` = 0
|
||||
');
|
||||
$cache_key = 'HotelRoomType::getHotelIdAddressByIdProduct'.(int)$id_product;
|
||||
if (!Cache::isStored($cache_key)) {
|
||||
$res = Db::getInstance()->getValue(
|
||||
'SELECT `id_address` from `'._DB_PREFIX_.'address` a
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt
|
||||
ON (hrt.`id_hotel` = a.`id_hotel`)
|
||||
WHERE hrt.`id_product` = '.(int)$id_product.' AND a.`deleted` = 0
|
||||
');
|
||||
Cache::store($cache_key, $res);
|
||||
} else {
|
||||
$res = Cache::retrieve($cache_key);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -671,9 +671,8 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
$context = Context::getContext();
|
||||
$id_currency = Validate::isLoadedObject($context->currency) ? (int)$context->currency->id : (int)Configuration::get('PS_CURRENCY_DEFAULT');
|
||||
|
||||
$hotelCartBookingData = new HotelCartBookingData();
|
||||
for($currentDate = date('Y-m-d', strtotime($date_from)); $currentDate < date('Y-m-d', strtotime($date_to)); $currentDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)))) {
|
||||
if ($use_reduc && ($featurePrice = $hotelCartBookingData->getProductFeaturePricePlanByDateByPriority(
|
||||
if ($use_reduc && ($featurePrice = HotelCartBookingData::getProductFeaturePricePlanByDateByPriority(
|
||||
$id_product,
|
||||
$currentDate,
|
||||
$id_group,
|
||||
@@ -826,8 +825,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel
|
||||
|
||||
$totalDurationPriceTI = $totalDurationPrice['total_price_tax_incl'];
|
||||
$totalDurationPriceTE = $totalDurationPrice['total_price_tax_excl'];
|
||||
$objHotelBookingDetail = new HotelBookingDetail();
|
||||
$numDaysInDuration = $objHotelBookingDetail->getNumberOfDays($dateFrom, $dateTo);
|
||||
$numDaysInDuration = HotelHelper::getNumberOfDays($dateFrom, $dateTo);
|
||||
if ($use_tax) {
|
||||
$pricePerDay = $totalDurationPriceTI/$numDaysInDuration;
|
||||
} else {
|
||||
|
||||
@@ -184,7 +184,6 @@ class RoomTypeServiceProduct extends ObjectModel
|
||||
true,
|
||||
$subCategory
|
||||
)) {
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$serviceProducts = Product::getProductsProperties($idLang, $serviceProducts);
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
foreach($serviceProducts as &$serviceProduct) {
|
||||
|
||||
@@ -267,10 +267,9 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
if ($getTotalPrice) {
|
||||
$totalPrice = 0;
|
||||
}
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$selectedServiceProducts = array();
|
||||
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
$selectedServiceProducts = array();
|
||||
if ($serviceProducts = Db::getInstance()->executeS($sql)) {
|
||||
foreach ($serviceProducts as $product) {
|
||||
$qty = $product['quantity'] ? (int)$product['quantity'] : 1;
|
||||
|
||||
Reference in New Issue
Block a user