public function getData() { if (!isset($this->_data)) { $shop = $this->getShop(); $lang = $this->getLang(); if (empty($this->_root_category)) { $root_category = Category::getRootCategory($lang, new Shop((int) Configuration::get('PS_SHOP_DEFAULT')))->id; } $categories = $new_selected_categories = array(); $selected_categories = Category::getAllCategoriesName($root_category, $lang, false, null, false); $categories[$root_category] = Category::getChildren($root_category, $lang, false, (int) Configuration::get('PS_SHOP_DEFAULT')); foreach ($selected_categories as $selected_category) { $category = new Category($selected_category['id_category'], $lang, (int) Configuration::get('PS_SHOP_DEFAULT')); $new_selected_categories[] = $selected_category['id_category']; $parents = $category->getParentsCategories($lang); foreach ($parents as $value) { $new_selected_categories[] = $value['id_category']; } } $new_selected_categories = array_unique($new_selected_categories); foreach ($new_selected_categories as $selected_category) { $current_category = Category::getChildren($selected_category, $lang, false, (int) Configuration::get('PS_SHOP_DEFAULT')); if (!empty($current_category)) { $categories[$selected_category] = $current_category; } } $tree = $this->fillTree($categories, $root_category); if (!empty($children)) { $tree[$root_category]['children'] = $children; } $this->setData($tree); } return $this->_data; }
public function initContent() { parent::initContent(); $shop = NULL; $alias_shop = (int) Tools::getValue('ash'); if (!empty($alias_shop)) { $_s = AphStore::getByAlias($alias_shop, Context::getContext()->language->id); $id_shop = $_s['id_shop']; } else { $id_shop = (int) Tools::getValue('ids'); } $shop = new AphStore($id_shop, Context::getContext()->language->id); $cover = NULL; $images = AphStoreImage::getImages(Context::getContext()->language->id, $id_shop); foreach ($images as &$image) { if (!empty($image['cover'])) { $cover = $image; } } if (empty($cover) && !empty($images)) { $cover = $images[0]; } $this->context->smarty->tpl_vars['meta_title']->value = $shop->name; $this->context->smarty->tpl_vars['meta_description']->value = $shop->meta_description; $products_by_category = array(); $categories = Category::getAllCategoriesName(NULL, Context::getContext()->language->id, true); if (!empty($categories)) { foreach ($categories as &$category) { if (Configuration::get('PS_ROOT_CATEGORY') == $category['id_category'] || Configuration::get('PS_HOME_CATEGORY') == $category['id_category']) { continue; } $products = AphStore::getProductsByStore($id_shop, Context::getContext()->language->id, NULL, NULL, 'name', 'desc', $category['id_category'], true); foreach ($products as &$product) { if (empty($products_by_category[$category['id_category']])) { $products_by_category[$category['id_category']] = array('id_category' => $category['id_category'], 'name' => $category['name'], 'class' => Tools::link_rewrite($category['name']), 'products' => array()); } $products_by_category[$category['id_category']]['products'][$product['id_product']] = array('id_product' => $product['id_product'], 'name' => $product['name'], 'link' => Context::getContext()->link->getProductLink((int) $product['id_product'], $product['link_rewrite'], $category['id_category'], $product['ean13'])); } } } $this->context->smarty->assign(array('shop' => $shop, 'cover' => $cover, 'images' => $images, 'products_by_category' => $products_by_category)); $this->context->controller->addCSS('/themes/aphrodinet/css/shop.css', 'all'); $this->setTemplate('shop.tpl'); }
public function initContent() { $result = array(); $this->display_column_left = false; $this->display_column_right = false; $search_data = Tools::getValue('to_search_data'); $city_cat_id = Tools::getValue('hotel_city_cat_id'); if (isset($search_data) && $search_data) { $return_data = $this->getHotelCategoryTree($search_data); if ($return_data) { $html = ''; foreach ($return_data as $key => $value) { $html .= '<li value="' . $value['id_category'] . '" tabindex="-1" class="search_result_li">' . $value['name'] . '</li>'; } $result['status'] = 'success'; $result['data'] = $html; } } else { if (isset($city_cat_id) && $city_cat_id) { $cat_ids = Category::getAllCategoriesName($city_cat_id); if ($cat_ids) { $html = ''; foreach ($cat_ids as $key => $value) { $hotel_info = $this->hotelBranchInfoByCategoryId($value['id_category']); if ($hotel_info) { $html .= '<li class="hotel_name" data-hotel-cat-id="' . $hotel_info['id_category'] . '">' . $hotel_info['hotel_name'] . '</li>'; } } $result['status'] = 'success'; $result['data'] = $html; } else { $result['status'] = 'failed2'; } } else { $result['status'] = 'failed3'; } } die(Tools::jsonEncode($result)); }
public function getData() { if (!isset($this->_data)) { $shop = $this->getShop(); $lang = $this->getLang(); $root_category = (int) $this->getRootCategory(); if ($this->_full_tree) { $this->setData(Category::getNestedCategories($root_category, $lang, false, null, $this->useShopRestriction())); $this->setDataSearch(Category::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction())); } else { if ($this->_children_only) { $categories[$root_category] = Category::getChildren($root_category, $lang, false, $shop->id); $children = $this->fillTree($categories, $root_category); $this->setData($children); } else { $new_selected_categories = array(); $selected_categories = $this->getSelectedCategories(); $categories[$root_category] = Category::getChildren($root_category, $lang, false, $shop->id); foreach ($selected_categories as $selected_category) { $category = new Category($selected_category, $lang, $shop->id); $new_selected_categories[] = $selected_category; $parents = $category->getParentsCategories($lang); foreach ($parents as $value) { $new_selected_categories[] = $value['id_category']; } } $new_selected_categories = array_unique($new_selected_categories); foreach ($new_selected_categories as $selected_category) { $current_category = Category::getChildren($selected_category, $lang, false, $shop->id); if (!empty($current_category)) { $categories[$selected_category] = $current_category; } } $tree = Category::getCategoryInformations(array($root_category), $lang); $children = $this->fillTree($categories, $root_category); if (!empty($children)) { $tree[$root_category]['children'] = $children; } $this->setData($tree); $this->setDataSearch(Category::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction())); } } } return $this->_data; }
public function deletePrestashopDefaultCategories() { $all_root_childrean_categories = Category::getAllCategoriesName(); foreach ($all_root_childrean_categories as $cat_key => $cat_value) { if ($cat_value['id_category'] > 2) { $obj_category = new Category($cat_value['id_category']); $obj_category->delete(); } } return true; }