kwintus Posted September 26, 2016 Share Posted September 26, 2016 Witam Panowie walcze z darmowym modułem do presty HomeCategories > https://www.prestashop.com/forums/topic/121735-free-module-homepage-categories-module/ Jak zrobić aby wyświetlało na stronie głównej nie kategorie root a kategorie podrzędne np. Menu > Produkty > Właściwe kategorie - wyświetlanie tylko podkategorii z kategorii "Produkty" Przerobiłem plik php: public function hookHeader() { Tools::addCSS(($this->_path).'homecategories.css', 'all'); } function hookHome($params) { global $smarty, $cookie, $link; $id_customer = (int)$params['cookie']->id_customer; $id_group = $id_customer ? Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_; $id_lang = (int)$params['cookie']->id_lang; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT c.*, cl.* FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.$id_lang.') LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`) WHERE level_depth > 1 And level_depth < 3 AND c.`active` = 1 AND cg.`id_group` = '.$id_group.' ORDER BY `level_depth` ASC, c.`position` ASC'); $category = new Category(1); $nb = intval(Configuration::get('HOME_categories_NBR')); global $link; $this->context->smarty->assign(array( 'categories' => $result, Category::getRootCategories(intval($params['cookie']->id_lang), false), 'link' => $link)); $this->context->smarty->assign(array( 'category' => $category, 'lang' => Language::getIsoById(intval($params['cookie']->id_lang)), )); $result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT c.*, cl.* FROM ps_category c LEFT JOIN `ps_category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.$id_lang.') LEFT JOIN ps_category_group cg ON (cg.`id_category` = c.`id_category`) WHERE level_depth > 2 And level_depth < 4 AND cg.`id_group` = '.$id_group.' AND c.`active` = 1 ORDER BY `level_depth` ASC, c.`position` ASC '); global $link; $this->context->smarty->assign(array( 'subcategories' => $result2, Category::getRootCategories(intval($params['cookie']->id_lang), true), 'sublink' => $link)); $this->context->smarty->assign(array( 'category' => $subcategory, 'lang' => Language::getIsoById(intval($params['cookie']->id_lang)), )); return $this->display(__FILE__, '/views/templates/hooks/homecategories.tpl'); } } Ale co dalej? Link to comment Share on other sites More sharing options...
vekia Posted September 26, 2016 Share Posted September 26, 2016 $category = new Category(1); wydaje mi sie, że wystarczy zmienić 1 na ID kategorii, od której ma być tworzone drzewo kategorii Link to comment Share on other sites More sharing options...
kwintus Posted September 26, 2016 Author Share Posted September 26, 2016 $category = new Category(1); wydaje mi sie, że wystarczy zmienić 1 na ID kategorii, od której ma być tworzone drzewo kategorii Też tak myślałem ale nie działa... Presta 1.6.1.3 Link to comment Share on other sites More sharing options...
atomek Posted September 26, 2016 Share Posted September 26, 2016 spróbuj tak:zamiastWHERE level_depth > 2 And level_depth < 4zmien warunek na:WHERE id_parent = 20 // <-- id kategorii nadrzędnej Link to comment Share on other sites More sharing options...
kwintus Posted September 27, 2016 Author Share Posted September 27, 2016 spróbuj tak: zamiast WHERE level_depth > 2 And level_depth < 4 zmien warunek na: WHERE id_parent = 20 // <-- id kategorii nadrzędnej Działa co prawda nie wyświetla miniatur ale działa! Podziękował Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now