Jump to content

Home Categories


kwintus

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...