QloApps icon indicating copy to clipboard operation
QloApps copied to clipboard

Add new rooms programmatically.

Open piyushvostro opened this issue 4 years ago • 5 comments

How to add new rooms programmatically from custom modules?

piyushvostro avatar Mar 20 '20 11:03 piyushvostro

@piyushvostro

To save the room information of a room type you have to make an entry in the htl_room_information table. Its related class is "HotelRoomInformation".

To save the disable dates information of a room, you have to make entries in the table htl_room_disable_dates. Its related class is "HotelRoomDisableDates".

Find all the above classes and tables in the module "hotelreservationsystem".

sumitwebkul avatar Mar 24 '20 14:03 sumitwebkul

Hello sir, can I have your email for an easy communication?

piyushvostro avatar Mar 24 '20 15:03 piyushvostro

@piyushvostro You can post here your issues. Here you will get your replies easily. There was a delay in the previous reply because of the situation due to coronavirus.

Thanks

sumitwebkul avatar Mar 24 '20 18:03 sumitwebkul

I have to create rooms(product) programmatically from a custom module. for this I am using this method -

$default_lang = Configuration::get('PS_LANG_DEFAULT'); $product = new Product(); $product->price = 2600; $product->id_supplier = 1; $product->quantity = 1; $product->save(); $product->id_category = 1; $product->id_category_default = 1; if($product->add()) { $product->updateCategories($product->id_category); StockAvailable::setQuantity((int)$product->id,0,$product->quantity, Context::getContext()->shop->id); }

This code is successfully creating a new product as can be seen in 'manage room types' tab under catalog tab in admin panel and also a new entry is created in ps_product table.

But how should I save additional information of this product (name, short_desc, desc, etc). As these details are saved in another table i.e ps-product_lang.

Thanks in Anticipation.

piyushvostro avatar Mar 25 '20 03:03 piyushvostro

@piyushvostro

We have built this software on the Prestashop eCommerce platform. We have used the product entity in Prestashop as the room type in QloApps. So we recommend you to follow the dev docs of Prestashop for the development help.

The room was additionally added and we have told ou the process to add rooms in the previous reply.

sumitwebkul avatar Mar 25 '20 10:03 sumitwebkul