0

我正在使用产品过滤器模块,在我的管理后端,我只能为第一级和第二级类别设置过滤器。我也需要添加第三级类别。下面提到的是我的模块控制器文件,

<?php
class ControllerModuleSuperCategoryMenu extends Controller {
    private $error = array(); 

    public function index() {   

        $this->data['current_version']='2.0.7';
        //remove cache files
        $this->cache->delete('product_filters');
        $this->cache->delete('attribute_filters');

        $this->load->language('module/supercategorymenu');

        $this->document->setTitle($this->language->get('heading_title'));

        $this->load->model('setting/setting');

        if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {        

        $this->model_setting_setting->editSetting('supercategorymenu', $this->request->post);       
        $this->session->data['success'] = $this->language->get('text_success');

        $this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
        }

        $this->data['heading_title'] = $this->language->get('heading_title');
        $this->data['tab_general'] = $this->language->get('tab_general');
        $this->data['tab_settings'] = $this->language->get('tab_settings');
        $this->data['tab_layouts'] = $this->language->get('tab_layouts');
        $this->data['tab_contact'] = $this->language->get('tab_contact');

        $this->data['entry_all_values']                     = $this->language->get('entry_all_values');
        $this->data['entry_list_number']                    = $this->language->get('entry_list_number');
        $this->data['entry_list_number_explanation']        = $this->language->get('entry_list_number_explanation');
        $this->data['entry_pricerange']                     = $this->language->get('entry_pricerange');
        $this->data['entry_pricerange_explanation']         = $this->language->get('entry_pricerange_explanation');
        $this->data['entry_set_vat']                        = $this->language->get('entry_set_vat');
        $this->data['entry_set_vat_explanation']            = $this->language->get('entry_set_vat_explanation');
        $this->data['default_vat_price_range']              = $this->language->get('default_vat_price_range');
        $this->data['default_vat_price_range_explanation']  = $this->language->get('default_vat_price_range_explanation');
        $this->data['entry_manufacturer']                   = $this->language->get('entry_manufacturer');
        $this->data['entry_manufacturer_explanation']       = $this->language->get('entry_manufacturer_explanation');
        $this->data['text_yes']                             = $this->language->get('text_yes');
        $this->data['text_no']                              = $this->language->get('text_no');
        $this->data['entry_count']                          = $this->language->get('entry_count');
        $this->data['entry_count_explanation']              = $this->language->get('entry_count_explanation');
        $this->data['entry_ocscroll']                       = $this->language->get('entry_ocscroll');
        $this->data['entry_ocscroll_explanation']           = $this->language->get('entry_ocscroll_explanation');
        $this->data['entry_nofollow']                       = $this->language->get('entry_nofollow');
        $this->data['entry_nofollow_explanation']           = $this->language->get('entry_nofollow_explanation');
        $this->data['entry_track_google']                   = $this->language->get('entry_track_google');
        $this->data['entry_track_google_explanation']       = $this->language->get('entry_track_google_explanation');
        $this->data['entry_ajax']                           = $this->language->get('entry_ajax');
        $this->data['entry_ajax_explanation']               = $this->language->get('entry_ajax_explanation');
        $this->data['entry_order']                          = $this->language->get('entry_order');
        $this->data['entry_order_explanation']              = $this->language->get('entry_order_explanation');




        $this->data['text_enabled'] = $this->language->get('text_enabled');
        $this->data['text_disabled'] = $this->language->get('text_disabled');
        $this->data['text_content_top'] = $this->language->get('text_content_top');
        $this->data['text_content_bottom'] = $this->language->get('text_content_bottom');       
        $this->data['text_column_left'] = $this->language->get('text_column_left');
        $this->data['text_column_right'] = $this->language->get('text_column_right');

        $this->data['entry_layout'] = $this->language->get('entry_layout');
        $this->data['entry_position'] = $this->language->get('entry_position');
        $this->data['entry_status'] = $this->language->get('entry_status');
        $this->data['entry_sort_order'] = $this->language->get('entry_sort_order');

        $this->data['entry_value'] = $this->language->get('entry_value');
        $this->data['entry_separator'] = $this->language->get('entry_separator');
        $this->data['entry_examples'] = $this->language->get('entry_examples');
        $this->data['entry_separator_explanation'] = $this->language->get('entry_separator_explanation');
        $this->data['entry_values_explanation'] = $this->language->get('entry_values_explanation');
        $this->data['text_none'] = $this->language->get('text_none');

        $this->data['button_save'] = $this->language->get('button_save');
        $this->data['button_cancel'] = $this->language->get('button_cancel');
        $this->data['button_add_module'] = $this->language->get('button_add_module');
        $this->data['button_remove'] = $this->language->get('button_remove');

        if (isset($this->error['warning'])) {
            $this->data['error_warning'] = $this->error['warning'];
        } else {
            $this->data['error_warning'] = '';
        }

        $this->data['breadcrumbs'] = array();

        $this->data['breadcrumbs'][] = array(
            'text'      => $this->language->get('text_home'),
            'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
            'separator' => false
        );

        $this->data['breadcrumbs'][] = array(
            'text'      => $this->language->get('text_module'),
            'href'      => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'),
            'separator' => ' :: '
        );

        $this->data['breadcrumbs'][] = array(
            'text'      => $this->language->get('heading_title'),
            'href'      => $this->url->link('module/supercategorymenu', 'token=' . $this->session->data['token'], 'SSL'),
            'separator' => ' :: '
        );

        $this->data['action'] = $this->url->link('module/supercategorymenu', 'token=' . $this->session->data['token'], 'SSL');
        $this->data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
        $this->data['settings'] = $this->url->link('module/supercategorymenu/settings', 'token=' . $this->session->data['token'], 'SSL');



        $this->data['modules'] = array();

        if (isset($this->request->post['supercategorymenu_module'])) {
            $this->data['modules'] = $this->request->post['supercategorymenu_module'];
        } elseif ($this->config->get('supercategorymenu_module')) { 
            $this->data['modules'] = $this->config->get('supercategorymenu_module');
        }   


        $this->data['settings'] = array();

        if (isset($this->request->post['supercategorymenu_settings'])) {
            $this->data['settings'] = $this->request->post['supercategorymenu_settings'];
        } elseif ($this->config->get('supercategorymenu_settings')) { 
            $this->data['settings'] = $this->config->get('supercategorymenu_settings');
        }           


        if (isset($this->data['settings']['track_google'])){
            $this->data['settings_trackgoogle']=$this->data['settings']['track_google'];

        }else{
            $this->data['settings_trackgoogle']=0;
        }



        if (isset($this->data['settings']['list_number'])){
            $this->data['settings_listnumber']=$this->data['settings']['list_number'];

        }else{
            $this->data['settings_listnumber']=7;
        }

        if (isset($this->data['settings']['nofollow'])){
            $this->data['settings_nofollow']=$this->data['settings']['nofollow'];

        }else{
            $this->data['settings_nofollow']=1;
        }

        if (isset($this->data['settings']['ajax'])){
            $this->data['settings_ajax']=$this->data['settings']['ajax'];

        }else{
            $this->data['settings_ajax']=0;
        }
        if (isset($this->data['settings']['order'])){
            $this->data['settings_order']=$this->data['settings']['order'];

        }else{
            $this->data['settings_order']="OH";
        }


        if (isset($this->data['settings']['ocscroll'])){
            $this->data['settings_ocscroll']=$this->data['settings']['ocscroll'];

        }else{
            $this->data['settings_ocscroll']=0;
        }


        if (isset($this->data['settings']['countp'])){
            $this->data['settings_countp']=$this->data['settings']['countp'];

        }else{
            $this->data['settings_countp']=1;
        }

        if (isset($this->data['settings']['pricerange'])){
            $this->data['settings_pricerange']=$this->data['settings']['pricerange'];

        }else{
            $this->data['settings_pricerange']=1;
        }

        if (isset($this->data['settings']['setvat'])){
            $this->data['settings_setvat']=$this->data['settings']['setvat'];

        }else{
            $this->data['settings_setvat']=1;
        }
        if (isset($this->data['settings']['manufacturer'])){
            $this->data['settings_manufacturer']=$this->data['settings']['manufacturer'];

        }else{
            $this->data['settings_manufacturer']=1;
        }
        if (isset($this->data['settings']['tax_class_id'])){
            $this->data['tax_class_id']=$this->data['settings']['tax_class_id'];

        }else{
            $this->data['tax_class_id']="";
        }

        $this->load->model('localisation/tax_class');

        $this->data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();


        $this->load->model('module/supercategorymenu');

        $this->data['categories'] = array();

        $categories = $this->model_module_supercategorymenu->getCategories(0);

        foreach ($categories as $category) {

            if (isset($this->request->post['VALORES_'.$category['category_id'].''])) {
                $this->data['category_attributes'][$category['category_id']]= $this->request->post['VALORES_'.$category['category_id'].''];
            } else {
                $this->data['category_attributes'][$category['category_id']] = $this->config->get('VALORES_'.$category['category_id'].'');
            }   

            $children_data = array();

            $children = $this->model_module_supercategorymenu->getCategories($category['category_id']);

            foreach ($children as $child) {


            if (isset($this->request->post['VALORES_'.$child['category_id'].''])) {
                $this->data['category_attributes'][$child['category_id']]= $this->request->post['VALORES_'.$child['category_id'].''];
            } else {
                $this->data['category_attributes'][$child['category_id']] = $this->config->get('VALORES_'.$child['category_id'].'');
            }   

            $results = $this->model_module_supercategorymenu->getCategoryAttributes($child['category_id']);                 

            $attribute_data = array();

            foreach ($results as $result) {

                        if (isset($this->data['category_attributes'][$child['category_id']]['attributes'][$result['attribute_id']])){
                            $attribute_checked=true;
                            $attribute_seperator=$this->data['category_attributes'][$child['category_id']]['attributes'][$result['attribute_id']]['separator']; 
                        }else{
                            $attribute_checked=false;
                            $attribute_seperator="no";
                        }

                $attribute_values=array();
                $attribute_values = $this->model_module_supercategorymenu->getAttributeValues($result['attribute_id']); 

                //foreach ($res as $attribute_value){
                    //$attribute_values[key($res)]=$attribute_value;

                //}

                $attribute_data[] = array(
                        'attribute_id'  => $result['attribute_id'],
                        'name'          => $result['name'],
                        'checked'       => $attribute_checked,
                        'separator'     => $attribute_seperator,
                        'attribute_values'=> $attribute_values
                    );                  


                }

                $children_data[] = array(
                    'category_id' => $child['category_id'],
                    'name'        => $child['name'],
                    'attributes'  => $attribute_data
                );                  
            }


            $results = $this->model_module_supercategorymenu->getCategoryAttributes($category['category_id']);  
            $attribute_data = array();

                foreach ($results as $result) {

                        if (isset($this->data['category_attributes'][$category['category_id']]['attributes'][$result['attribute_id']])){
                            $attribute_checked=true;
                            $attribute_seperator=$this->data['category_attributes'][$category['category_id']]['attributes'][$result['attribute_id']]['separator'];  
                        }else{
                            $attribute_checked=false;
                            $attribute_seperator="no";
                        }
                $attribute_values_child=array();
                $attribute_values_child = $this->model_module_supercategorymenu->getAttributeValues($result['attribute_id']);   

                //foreach ($res_child as $attribute_value_child){
                    //$attribute_values_child[key($res)]=$attribute_value_child;

                //}


                $attribute_data[] = array(
                        'attribute_id'  => $result['attribute_id'],
                        'name'          => $result['name'],
                        'checked'       => $attribute_checked,
                        'separator'     => $attribute_seperator,
                        'attribute_values'=> $attribute_values_child
                    );                  


                }


            $this->data['categories'][] = array(
                'category_id' => $category['category_id'],
                'name'        => $category['name'],
                'children'    => $children_data,
                'attributes'  => $attribute_data,
                //'valores_bd'  => $this->data['category_attributes'][$category['category_id']]


            );
        }


        $this->load->model('setting/extension');

        if(in_array("ocscroll",$this->model_setting_extension->getInstalled('module'))){
            $this->data['ocscroll']=true;
        }else{
           $this->data['ocscroll']=false;
        }

            $ch = curl_init();
             // Now set some options (most are optional)
             // Set URL to download
             curl_setopt($ch, CURLOPT_URL,"http://opencart.tictachome.com/version/version.xml");
            // Include header in result? (0 = yes, 1 = no)
             curl_setopt($ch, CURLOPT_HEADER, 0);
            // Should cURL return or print out the data? (true = return, false = print)
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            // Timeout in seconds
             curl_setopt($ch, CURLOPT_TIMEOUT, 10);
            // Download the given URL, and return output
            $output = curl_exec($ch);
            // Close the cURL resource, and free system resources
            curl_close($ch);
            $analizador=simplexml_load_string($output,null);

            $this->data['version']['version']=$analizador->children()->version;
            $this->data['version']['whats_new']=$analizador->children()->whats_new;

        foreach($analizador->children()->other_modules as $other_modules){

            $this->data['version']['modules'][]=array(

                    'name'      =>$other_modules->name,
                    'version'   =>$other_modules->version,
                    'url'       =>$other_modules->url,
                    'manual'    =>$other_modules->manual,
                    'price'     =>$other_modules->price,
                    'resume'    =>$other_modules->resume,
                );

            }




        $this->load->model('localisation/language');

        $this->data['languages'] = $this->model_localisation_language->getLanguages();

        $this->load->model('design/layout');

        $this->data['layouts'] = $this->model_design_layout->getLayouts();

        $this->template = 'module/supercategorymenu.tpl';
        $this->children = array(
            'common/header',
            'common/footer'
        );

        $this->response->setOutput($this->render());
    }

    private function validate() {
        if (!$this->user->hasPermission('modify', 'module/supercategorymenu')) {
            $this->error['warning'] = $this->language->get('error_permission');
        }

        if (!$this->error) {
            return true;
        } else {
            return false;
        }   
    }
}
?>

有没有人知道如何添加第三级类别呢..

请分享您的建议。

谢谢,

4

0 回答 0