Fixed: Room type categories were not updated when hotel name or location is updated

This commit is contained in:
Shreesh Arora
2024-03-27 15:37:50 +05:30
parent 2268abe924
commit 127fbbef24
2 changed files with 22 additions and 0 deletions

View File

@@ -825,6 +825,23 @@ class HotelBranchInformation extends ObjectModel
return true;
}
public function updateRoomTypeCategories()
{
if (!Validate::isLoadedObject($this)) {
return false;
}
$hotelCategories = $this->getAllHotelCategories();
$objHotelRoomType = new HotelRoomType();
if ($roomTypes = $objHotelRoomType->getRoomTypeByHotelId($this->id, Context::getContext()->language->id)) {
foreach ($roomTypes as $roomType) {
$objProduct = new Product($roomType['id_product']);
$productCategories = $objProduct->getCategories();
$objProduct->updateCategories($hotelCategories);
}
}
}
public function isRefundable()
{
return (Configuration::get('WK_ORDER_REFUND_ALLOWED') && $this->active_refund);

View File

@@ -534,7 +534,9 @@ class AdminAddHotelController extends ModuleAdminController
if ($objHotelBranch->id_category) {
$objCategory = new Category($objHotelBranch->id_category);
$objCategory->name = $objHotelBranch->hotel_name;
$objCategory->id_parent = $catCity;
$objCategory->save();
Category::regenerateEntireNtree();
} else {
if ($catHotel = $objHotelBranch->addCategory(
$hotelCatName, $catCity, $groupIds, 1, $newIdHotel, $linkRewriteArray
@@ -566,6 +568,9 @@ class AdminAddHotelController extends ModuleAdminController
}
}
// update room types association after category update
$objHotelBranch->updateRoomTypeCategories();
if ($idHotel) {
// save maximum booking date and preparation time
$objHotelOrderRestrictDate = new HotelOrderRestrictDate();