Example #1
0
 public function hookproductratingHook($params)
 {
     $product = $params['productid'];
     include_once _PS_MODULE_DIR_ . 'productcomments/ProductComment.php';
     if (!isset($product)) {
         return;
     }
     $grade = ProductComment::getAverageGrade($product);
     $this->context->smarty->assign(array('empty_grade' => 1));
     if (isset($grade['grade'])) {
         $this->context->smarty->assign(array('empty_grade' => 0));
     }
     $this->context->smarty->assign(array('average_total' => round($grade['grade']), 'nbComments' => (int) ProductComment::getCommentNumber((int) $product)));
     $this->context->smarty->assign((int) ProductComment::getCommentNumber((int) $product));
     return $this->display(__FILE__, 'ratingsproductlist.tpl');
 }
Example #2
0
 public function hookproductOutOfStock($params)
 {
     require_once dirname(__FILE__) . '/ProductComment.php';
     require_once dirname(__FILE__) . '/ProductCommentCriterion.php';
     $id_guest = !($id_customer = (int) $this->context->cookie->id_customer) ? (int) $this->context->cookie->id_guest : false;
     $customerComment = ProductComment::getByCustomer((int) Tools::getValue('id_product'), (int) $this->context->cookie->id_customer, true, (int) $id_guest);
     $average = ProductComment::getAverageGrade((int) Tools::getValue('id_product'));
     $image = Product::getCover((int) Tools::getValue('id_product'));
     $this->context->smarty->assign(array('id_product_comment_form' => (int) Tools::getValue('id_product'), 'product' => new Product((int) Tools::getValue('id_product'), false, $this->context->language->id), 'secure_key' => $this->secure_key, 'logged' => (int) $this->context->customer->isLogged(true), 'allow_guests' => (int) Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'), 'productcomment_cover' => (int) Tools::getValue('id_product') . '-' . (int) $image['id_image'], 'mediumSize' => Image::getSize('medium'), 'criterions' => ProductCommentCriterion::getByProduct((int) Tools::getValue('id_product'), $this->context->language->id), 'action_url' => '', 'averageTotal' => (int) $average['grade'], 'too_early' => $customerComment && strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME') > time(), 'nbComments' => (int) ProductComment::getCommentNumber((int) Tools::getValue('id_product'))));
     return $this->display(__FILE__, '/productcomments-extra.tpl');
 }
    function content_55574d9fd07494_75530310($_smarty_tpl)
    {
        ?>
 
<?php 
        if (!$_smarty_tpl->tpl_vars['content_only']->value && ($_smarty_tpl->tpl_vars['nbComments']->value == 0 && $_smarty_tpl->tpl_vars['too_early']->value == false && ($_smarty_tpl->tpl_vars['is_logged']->value || $_smarty_tpl->tpl_vars['allow_guests']->value) || $_smarty_tpl->tpl_vars['nbComments']->value != 0)) {
            ?>



<div id="product_comments_block_extra" class="no-print" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<?php 
            $_smarty_tpl->tpl_vars["nbComments"] = new Smarty_variable(ProductComment::getCommentNumber($_smarty_tpl->tpl_vars['id_product_comment_form']->value), null, 0);
            $_smarty_tpl->tpl_vars["ratings"] = new Smarty_variable(ProductComment::getRatings($_smarty_tpl->tpl_vars['id_product_comment_form']->value), null, 0);
            $_smarty_tpl->tpl_vars["average"] = new Smarty_variable(ProductComment::getAverageGrade($_smarty_tpl->tpl_vars['id_product_comment_form']->value), null, 0);
            $_smarty_tpl->tpl_vars["averageTotal"] = new Smarty_variable(round($_smarty_tpl->tpl_vars['average']->value['grade']), null, 0);
            ?>
	<?php 
            if ($_smarty_tpl->tpl_vars['nbComments']->value != 0) {
                ?>
		<div class="comments_note clearfix">
			<div class="star_content clearfix">
				<?php 
                if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']["i"])) {
                    unset($_smarty_tpl->tpl_vars['smarty']->value['section']["i"]);
                }
                $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['name'] = "i";
                $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['start'] = (int) 0;
                $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['loop'] = is_array($_loop = 5) ? count($_loop) : max(0, (int) $_loop);
                unset($_loop);
                $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['step'] = (int) 1 == 0 ? 1 : (int) 1;
                $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['show'] = true;
                $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['loop'];
                if ($_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['start'] < 0) {
                    $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['start'] = max($_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['step'] > 0 ? 0 : -1, $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['loop'] + $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['start']);
                } else {
                    $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['start'] = min($_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['step'] > 0 ? $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['loop'] : $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['loop'] - 1);
                }
                if ($_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['show']) {
                    $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['total'] = min(ceil(($_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['step'] > 0 ? $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['loop'] - $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['start'] : $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['start'] + 1) / abs($_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['step'])), $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['max']);
                    if ($_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['total'] == 0) {
                        $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['show'] = false;
                    }
                } else {
                    $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['total'] = 0;
                }
                if ($_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['show']) {
                    for ($_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['iteration'] = 1; $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['total']; $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['iteration']++) {
                        $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['iteration'];
                        $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['step'];
                        $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['step'];
                        $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['first'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['iteration'] == 1;
                        $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['last'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']["i"]['total'];
                        ?>
					<?php 
                        if ($_smarty_tpl->tpl_vars['averageTotal']->value <= $_smarty_tpl->getVariable('smarty')->value['section']['i']['index']) {
                            ?>
						<div class="star"></div>
					<?php 
                        } else {
                            ?>
						<div class="star star_on"></div>
					<?php 
                        }
                        ?>
				<?php 
                    }
                }
                ?>
				<meta itemprop="worstRating" content = "0" />
				<meta itemprop="ratingValue" content = "<?php 
                if (isset($_smarty_tpl->tpl_vars['ratings']->value['avg'])) {
                    echo htmlspecialchars(round($_smarty_tpl->tpl_vars['ratings']->value['avg'], 1), ENT_QUOTES, 'UTF-8', true);
                } else {
                    echo htmlspecialchars(round($_smarty_tpl->tpl_vars['averageTotal']->value, 1), ENT_QUOTES, 'UTF-8', true);
                }
                ?>
" />
				<meta itemprop="bestRating" content = "5" />
			</div>
		</div> <!-- .comments_note -->
	<?php 
            }
            ?>

	<ul class="comments_advices">
		<?php 
            if ($_smarty_tpl->tpl_vars['nbComments']->value != 0) {
                ?>
			<li>
				<a href="#idTab5" class="reviews">
					<?php 
                echo smartyTranslate(array('s' => 'Based on', 'mod' => 'productcomments'), $_smarty_tpl);
                ?>
 <span itemprop="reviewCount"><?php 
                echo $_smarty_tpl->tpl_vars['nbComments']->value;
                ?>
</span> <?php 
                echo smartyTranslate(array('s' => 'ratings', 'mod' => 'productcomments'), $_smarty_tpl);
                ?>

				</a>
			</li>
		<?php 
            }
            ?>
		<?php 
            if ($_smarty_tpl->tpl_vars['too_early']->value == false && ($_smarty_tpl->tpl_vars['is_logged']->value || $_smarty_tpl->tpl_vars['allow_guests']->value)) {
                ?>
			<li>
				<a class="open-comment-form" href="#new_comment_form">
					<?php 
                echo smartyTranslate(array('s' => 'Write a review', 'mod' => 'productcomments'), $_smarty_tpl);
                ?>

				</a>
			</li>
		<?php 
            }
            ?>
	</ul>
</div>
<?php 
        }
        ?>
<!--  /Module ProductComments -->
<?php 
    }
 public function displayTop()
 {
     //if (!$this->isCached('blocktopmenu2.tpl', $this->getCacheId()))
     //{
     $this->user_groups = $this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP'));
     $categoryMain = current(Category::getNestedCategories(146, $this->context->language->id, true, $this->user_groups));
     //$this->loadCategories(146);
     //            $categoryComplects = new Category(129, $this->context->language->id);
     //            $categoryWholesale = new Category(148, $this->context->language->id);
     //            $cmsopt = new CMS(11, $this->context->language->id);
     $categoryComplects = current(Category::getNestedCategories(129, $this->context->language->id, true, $this->user_groups));
     $categoryComplectsDecor = current(Category::getNestedCategories(198, $this->context->language->id, true, $this->user_groups));
     $categoryFurniture = current(Category::getNestedCategories(7, $this->context->language->id, true, $this->user_groups));
     //$this->loadCategories(7);
     $shop_id = (int) $this->context->shop->id;
     $shop_group_id = Shop::getGroupFromShop($shop_id);
     $item_day_id = Db::getInstance()->getValue("SELECT id_product FROM " . _DB_PREFIX_ . "product WHERE item_for_day=1  AND active=1 ORDER BY RAND()");
     if ($item_day_id) {
         require_once dirname(dirname(__FILE__)) . '/productcomments/ProductComment.php';
         $prodict_day = new Product($item_day_id, true, $this->context->language->id, $this->context->shop->id);
         $average = ProductComment::getAverageGrade($prodict_day->id);
         $cover = Product::getCover((int) $prodict_day->id, $this->context);
         $this->context->smarty->assign(array('priceDisplayPrecisionDay' => _PS_PRICE_DISPLAY_PRECISION_, 'have_image_day' => isset($cover['id_image']) && (int) $cover['id_image'] ? true : false, 'cover_day' => $cover, 'categoryComplects' => $categoryComplects, 'categoryComplectsDecor' => $categoryComplectsDecor, 'averageTotalDay' => round($average['grade']), 'ratingsDay' => ProductComment::getRatings((int) $prodict_day->id), 'nbCommentsDay' => (int) ProductComment::getCommentNumber((int) $prodict_day->id)));
     } else {
         $prodict_day = null;
     }
     $this->context->smarty->assign(array('prodict_day' => $prodict_day, 'prodict_day_url' => is_object($prodict_day) ? $this->context->link->getProductLink($prodict_day) : null, 'search' => Configuration::get('MOD_blocktopmenu2_SEARCH', null, $shop_group_id, $shop_id), 'categoryMain' => $categoryMain, 'categoryComplects' => $categoryComplects, 'categoryComplectsDecor' => $categoryComplectsDecor, 'categoryWholesale' => new Category(148, $this->context->language->id), 'cmsopt' => new CMS(11, $this->context->language->id), 'categoryFurniture' => $categoryFurniture));
     // echo '<pre>'; var_dump($this->context->smarty->getTemplateVars('categoryMain')); echo '</pre>'; die();
     //}
     return $this->display(__FILE__, 'blocktopmenu2.tpl', $this->getCacheId());
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if (!$this->errors) {
         if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
             $this->product->quantity = 0;
         }
         $this->product->description = $this->transformDescriptionWithImg($this->product->description);
         // Assign to the template the id of the virtual product. "0" if the product is not downloadable.
         $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
         $this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
         if (Tools::isSubmit('submitCustomizedDatas')) {
             // If cart has not been saved, we need to do it so that customization fields can have an id_cart
             // We check that the cookie exists first to avoid ghost carts
             if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
                 $this->context->cart->add();
                 $this->context->cookie->id_cart = (int) $this->context->cart->id;
             }
             $this->pictureUpload();
             $this->textRecord();
             $this->formTargetFormat();
         } elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
             $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
         }
         $pictures = array();
         $text_fields = array();
         if ($this->product->customizable) {
             $files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
             foreach ($files as $file) {
                 $pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
             }
             $texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
             foreach ($texts as $text_field) {
                 $text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
             }
         }
         $this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
         $this->product->customization_required = false;
         $customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
         if (is_array($customization_fields)) {
             foreach ($customization_fields as $customization_field) {
                 if ($this->product->customization_required = $customization_field['required']) {
                     break;
                 }
             }
         }
         // Assign template vars related to the category + execute hooks related to the category
         $this->assignCategory();
         // Assign template vars related to the price and tax
         $this->assignPriceAndTax();
         // Assign template vars related to the images
         $this->assignImages();
         // Assign attribute groups to the template
         $this->assignAttributesGroups();
         // Assign attributes combinations to the template
         $this->assignAttributesCombinations();
         // Pack management
         $pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
         $this->context->smarty->assign('packItems', $pack_items);
         $this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
         if (isset($this->category->id) && $this->category->id) {
             $return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
         } else {
             $return_link = 'javascript: history.back();';
         }
         $accessories = $this->product->getAccessories($this->context->language->id);
         if ($this->product->cache_is_pack || count($accessories)) {
             $this->context->controller->addCSS(_THEME_CSS_DIR_ . 'product_list.css');
         }
         if ($this->product->customizable) {
             $customization_datas = $this->context->cart->getProductCustomization($this->product->id, null, true);
         }
         // by webkul
         $htl_features = array();
         $obj_hotel_room_type = new HotelRoomType();
         $room_info_by_product_id = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($this->product->id);
         $hotel_id = $room_info_by_product_id['id_hotel'];
         if (isset($hotel_id) && $hotel_id) {
             $obj_hotel_branch = new HotelBranchInformation();
             $hotel_info_by_id = $obj_hotel_branch->hotelBranchInfoById($hotel_id);
             $hotel_policies = $hotel_info_by_id['policies'];
             $hotel_name = $hotel_info_by_id['hotel_name'];
             $country = Country::getNameById($this->context->language->id, $hotel_info_by_id['country_id']);
             $state = State::getNameById($hotel_info_by_id['state_id']);
             $hotel_location = $hotel_info_by_id['city'] . ', ' . $state . ', ' . $country;
             $obj_hotel_feaures_ids = $obj_hotel_branch->getFeaturesOfHotelByHotelId($hotel_id);
             if (isset($obj_hotel_feaures_ids) && $obj_hotel_feaures_ids) {
                 foreach ($obj_hotel_feaures_ids as $key => $value) {
                     $obj_htl_ftr = new HotelFeatures();
                     $htl_info = $obj_htl_ftr->getFeatureInfoById($value['feature_id']);
                     $htl_features[] = $htl_info['name'];
                 }
             }
         }
         $date_from = Tools::getValue('date_from');
         $date_to = Tools::getValue('date_to');
         if (!($date_from = Tools::getValue('date_from'))) {
             $date_from = date('Y-m-d');
             $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         }
         if (!($date_to = Tools::getValue('date_to'))) {
             $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         }
         $obj_booking_detail = new HotelBookingDetail();
         $num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to);
         $priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id);
         if (!$priceDisplay || $priceDisplay == 2) {
             $price_tax = true;
         } elseif ($priceDisplay == 1) {
             $price_tax = false;
         }
         $price_tax_incl = Product::getPriceStatic($this->product->id, $price_tax);
         $total_price = $price_tax_incl * $num_days;
         $obj_booking_dtl = new HotelBookingDetail();
         $hotel_room_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $hotel_id, $this->product->id, 1);
         $obj_htl_cart_booking_data = new HotelCartBookingData();
         $num_cart_rooms = $obj_htl_cart_booking_data->getCountRoomsByIdCartIdProduct($this->context->cart->id, $this->product->id, $date_from, $date_to);
         if ($hotel_room_data) {
             $total_available_rooms = $hotel_room_data['stats']['num_avail'] - $num_cart_rooms;
         }
         //end
         $location_enable = Configuration::get('WK_HOTEL_LOCATION_ENABLE');
         $hotel_branch_obj = new HotelBranchInformation();
         $hotel_info = $hotel_branch_obj->getActiveHotelBranchesInfo();
         $search_data['date_from'] = $date_from;
         $search_data['date_to'] = $date_to;
         $search_data['htl_dtl'] = $hotel_branch_obj->hotelBranchInfoById($hotel_id);
         if (Tools::getValue('error')) {
             $this->context->smarty->assign('error', Tools::getValue('error'));
         }
         $this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customization_fields, 'id_customization' => empty($customization_datas) ? null : $customization_datas[0]['id_customization'], 'accessories' => $accessories, 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'ratting_img_path' => _MODULE_DIR_ . 'hotelreservationsystem/views/img/Slices/icons-sprite.png', 'num_reviews' => ProductComment::getCommentNumber($this->product->id), 'ratting' => ProductComment::getAverageGrade($this->product->id)['grade'], 'total_available_rooms' => $total_available_rooms, 'all_hotels_info' => $hotel_info, 'location_enable' => $location_enable, 'total_price' => $total_price, 'product_controller_url' => $this->context->link->getPageLink('product'), 'num_days' => $num_days, 'date_from' => $date_from, 'date_to' => $date_to, 'hotel_location' => $hotel_location, 'hotel_name' => $hotel_name, 'hotel_policies' => $hotel_policies, 'hotel_features' => $htl_features, 'ftr_img_src' => _PS_IMG_ . 'rf/', 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE'), 'search_data' => $search_data));
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
 }
 public function DataForFrontSearch($date_from, $date_to, $id_hotel, $id_product = 0, $for_room_type = 0, $adult = 0, $children = 0, $ratting = -1, $amenities = 0, $price = 0, $id_cart = 0, $id_guest = 0)
 {
     require_once _PS_MODULE_DIR_ . 'productcomments/ProductComment.php';
     $this->context = Context::getContext();
     $booking_data = $this->getBookingData($date_from, $date_to, $id_hotel, $id_product, $adult, $children, 0, 0, 1, 0, 0, 0, $id_cart, $id_guest);
     // ddd($booking_data);
     if (!$for_room_type) {
         if (!empty($booking_data)) {
             $obj_rm_type = new HotelRoomType();
             foreach ($booking_data['rm_data'] as $key => $value) {
                 if (empty($value['data']['available'])) {
                     unset($booking_data['rm_data'][$key]);
                 } else {
                     $prod_ratting = ProductComment::getAverageGrade($value['id_product'])['grade'];
                     if ($prod_ratting === NULL) {
                         $prod_ratting = 0;
                     }
                     if ($prod_ratting < $ratting && $ratting != -1) {
                         unset($booking_data['rm_data'][$key]);
                     } else {
                         $product = new Product($value['id_product'], false, $this->context->language->id);
                         $product_feature = $product->getFrontFeaturesStatic($this->context->language->id, $value['id_product']);
                         $prod_amen = array();
                         if (!empty($amenities) && $amenities) {
                             $prod_amen = $amenities;
                             foreach ($product_feature as $a_key => $a_val) {
                                 if (($pa_key = array_search($a_val['id_feature'], $prod_amen)) !== false) {
                                     unset($prod_amen[$pa_key]);
                                     if (empty($prod_amen)) {
                                         break;
                                     }
                                 }
                             }
                             if (!empty($prod_amen)) {
                                 unset($booking_data['rm_data'][$key]);
                             }
                         }
                         if (empty($prod_amen)) {
                             $prod_price = Product::getPriceStatic($value['id_product']);
                             if (empty($price) || $price['from'] <= $prod_price && $price['to'] >= $prod_price) {
                                 $cover_image_arr = $product->getCover($value['id_product']);
                                 if (!empty($cover_image_arr)) {
                                     $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . $cover_image_arr['id_image'], 'home_default');
                                 } else {
                                     $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code . "-default", 'home_default');
                                 }
                                 $room_left = count($booking_data['rm_data'][$key]['data']['available']);
                                 $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($value['id_product']);
                                 $booking_data['rm_data'][$key]['name'] = $product->name;
                                 $booking_data['rm_data'][$key]['image'] = $cover_img;
                                 $booking_data['rm_data'][$key]['description'] = $product->description_short;
                                 $booking_data['rm_data'][$key]['feature'] = $product_feature;
                                 $booking_data['rm_data'][$key]['price'] = $prod_price;
                                 if ($room_left <= (int) Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER')) {
                                     $booking_data['rm_data'][$key]['room_left'] = $room_left;
                                 }
                                 $booking_data['rm_data'][$key]['adult'] = $rm_dtl['adult'];
                                 $booking_data['rm_data'][$key]['children'] = $rm_dtl['children'];
                                 $booking_data['rm_data'][$key]['ratting'] = $prod_ratting;
                                 $booking_data['rm_data'][$key]['num_review'] = ProductComment::getCommentNumber($value['id_product']);
                                 if (Configuration::get('PS_REWRITING_SETTINGS')) {
                                     $booking_data['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product) . '?date_from=' . $date_from . '&date_to=' . $date_to;
                                 } else {
                                     $booking_data['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product) . '&date_from=' . $date_from . '&date_to=' . $date_to;
                                 }
                             } else {
                                 unset($booking_data['rm_data'][$key]);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $booking_data;
 }