public function hookDisplayLeftColumn() { if ($this->context->controller->php_self == 'category') { $this->context->controller->addJS(_PS_MODULE_DIR_ . $this->name . '/views/js/wkhotelfilterblock.js'); $this->context->controller->addCSS(_PS_MODULE_DIR_ . $this->name . '/views/css/wkhotelfilterblock.css'); $all_feat = FeatureCore::getFeatures($this->context->language->id); $htl_id_category = Tools::getValue('id_category'); $id_hotel = HotelBranchInformation::getHotelIdByIdCategory($htl_id_category); $max_adult = HotelRoomType::getMaxAdults($id_hotel); $max_child = HotelRoomType::getMaxChild($id_hotel); $category = new Category($htl_id_category); 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_rm_type = new HotelRoomType(); $room_types = $obj_rm_type->getIdProductByHotelId($id_hotel); $prod_price = array(); if ($room_types) { foreach ($room_types as $key => $value) { $prod_price[] = Product::getPriceStatic($value['id_product']); } } if (Configuration::get('PS_REWRITING_SETTINGS')) { $cat_link = $this->context->link->getCategoryLink($category) . '?date_from=' . $date_from . '&date_to=' . $date_to; } else { $cat_link = $this->context->link->getCategoryLink($category) . '&date_from=' . $date_from . '&date_to=' . $date_to; } $currency = $this->context->currency; $config = $this->getConfigFieldsValues(); $obj_booking_detail = new HotelBookingDetail(); $num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to); $ratting_img = _MODULE_DIR_ . $this->name . '/views/img/stars-sprite-image.png'; $this->context->smarty->assign(array('all_feat' => $all_feat, 'max_adult' => $max_adult, 'max_child' => $max_child, 'cat_link' => $cat_link, 'ratting_img' => $ratting_img, 'currency' => $currency, 'date_from' => $date_from, 'date_to' => $date_to, 'num_days' => $num_days, 'config' => $config, 'min_price' => $prod_price ? min($prod_price) : 0, 'max_price' => $prod_price ? max($prod_price) : 0)); return $this->display(__FILE__, 'htlfilterblock.tpl'); } }
public static function getFeaturesForComparison($list_ids_product, $id_lang) { $features = parent::getFeaturesForComparison($list_ids_product, $id_lang); $fids = array(); foreach ($features as $feature) { $fids[$feature['id_feature']] = 1; } $records = Db::getInstance()->ExecuteS(' SELECT f.id_feature, fg.id_group, fgl.name, f.position AS feature_position, fg.position AS group_position FROM ' . _DB_PREFIX_ . 'feature f JOIN ' . _DB_PREFIX_ . 'feature_group fg ON f.id_group=fg.id_group JOIN ' . _DB_PREFIX_ . 'feature_group_lang fgl ON (fg.id_group = fgl.id_group AND fgl.id_lang=' . intval($id_lang) . ') WHERE f.id_feature IN (' . implode(',', array_keys($fids)) . ')'); if (!$records) { return null; } $result = array(); foreach ($records as $rec) { if (!array_key_exists($rec["id_group"], $result)) { $result[$rec["id_group"]] = array("name" => $rec["name"], "position" => $rec["group_position"], 'features' => array()); } foreach ($features as $feature) { if ($feature["id_feature"] == $rec["id_feature"]) { $feature["position"] = $rec["feature_position"]; $result[$rec["id_group"]]["features"][$feature["id_feature"]] = $feature; } } } uasort($result, array("Feature", 'sortFeaturesGroupsByPositionCallback')); foreach ($result as $group_id => &$group_data) { uasort($group_data["features"], array("Feature", 'sortFeaturesByPositionCallback')); } return $result; }
/** * Get all features for a given language * * @param int $id_lang Language id * @param bool $with_shop * @return array Multiple arrays with feature's data */ public static function getFeatures($id_lang, $with_shop = true) { return \FeatureCore::getFeatures($id_lang, $with_shop); }
/** * Creates product features in Prestashop. * * @param integer $id_product * @param integer $language * @param array $array_features_product * @return * */ private function addFeaturesForProducts($id_product, $language, $array_features_product) { $feature_product = new FeatureCore(); $feature_product_value = new FeatureValueCore(); $id_feature_width = $feature_product->addFeatureImport("Larghezza"); $id_feature_height = $feature_product->addFeatureImport("Altezza"); $id_feature_size = $feature_product->addFeatureImport("Lunghezza"); $id_feature_model = $feature_product->addFeatureImport("Modello"); $id_feature_collez = $feature_product->addFeatureImport("Linea"); $array_id_features = array(); array_push($array_id_features, $id_feature_width); array_push($array_id_features, $id_feature_height); array_push($array_id_features, $id_feature_size); array_push($array_id_features, $id_feature_model); array_push($array_id_features, $id_feature_collez); $string_value_width = $array_features_product["Larghezza"] . " cm"; $string_value_height = $array_features_product["Altezza"] . " cm"; $string_value_size = $array_features_product["Lunghezza"] . " cm"; $string_value_model = $array_features_product["Modello"]; $string_value_collez = $array_features_product["Linea"]; $array_id_feature_value = array(); array_push($array_id_feature_value, $feature_product_value->addFeatureValueImport($id_feature_width, $string_value_width, (int) $id_product, $language)); array_push($array_id_feature_value, $feature_product_value->addFeatureValueImport($id_feature_height, $string_value_height, (int) $id_product, $language)); array_push($array_id_feature_value, $feature_product_value->addFeatureValueImport($id_feature_size, $string_value_size, (int) $id_product, $language)); array_push($array_id_feature_value, $feature_product_value->addFeatureValueImport($id_feature_model, $string_value_model, (int) $id_product, $language)); array_push($array_id_feature_value, $feature_product_value->addFeatureValueImport($id_feature_collez, $string_value_collez, (int) $id_product, $language)); $size_feature_value = sizeof($array_id_feature_value); $product = new Product((int) $id_product); for ($i = 0; $i < $size_feature_value; $i++) { $product->addFeaturesToDB($array_id_features[$i], $array_id_feature_value[$i]); } }
/** * Return if Feature feature is active or not * @return bool */ public function featureIsActive() { return \FeatureCore::isFeatureActive(); }