简体   繁体   中英

500 Internal Server Error while installing a rewritten OpenCart 1.5 module in OpenCart 2.0

I need to install a module that is compatible with OpenCart 1.5 on OpenCart 2. Installation went successfully but I got the following error: indirect modification OpenCart. I tried to rewrite the code of the module in admin/controller/modules/mymodule.php . After applying the following code I get Error 500 when try to edit module's settings. What could be wrong and where I am mistaking?

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

    public function index() {
        $this->load->language('module/XDCategoryGroups');

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

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

        //VALUE ASSIGNMENT
       $data=array();

        $data['heading_title'] = $this->language->get('heading_title');
        $data['error_warning'] = '';
        $data['XD_settings_title'] = $this->language->get('XD_settings_title');
        $data['text_image_manager'] = 'Upload Media';
        $data['XD_title'] = $this->language->get('XD_title');
        $data['XD_image'] = $this->language->get('XD_image');
        $data['XD_category'] = $this->language->get('XD_category');
        $data['button_save'] = $this->language->get('button_save');
        $data['button_cancel'] = $this->language->get('button_cancel');
        $data['token'] = $this->session->data['token'];

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

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

        //BREADCRUMBS
        $data['breadcrumbs'] = array();

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

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

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


        //LAYOUT OPTIONS

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

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

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

        $results = $this->model_catalog_category->getCategories(0);


        //print_r($results);

        foreach ($results as $result) {


                $data['categories'][] = array(
                        'category_id' => $result['category_id'],
                   'name'        => $result['name']
                );

       }

        //SAVE OR GET LAYOUT OPTIONS
        $data['modules'] = array();     
        if (isset($this->request->post['XDCategoryGroups_module'])) {
                $data['modules'] = $this->request->post['XDCategoryGroups_module'];
        } elseif ($this->config->get('XDCategoryGroups_module')) { 
                $data['modules'] = $this->config->get('XDCategoryGroups_module');
        }

        //SAVE OR GET BLOCKS
        $data['blocks'] = array();      
        if (isset($this->request->post['XDCategoryGroupsBlocks'])) {
                $data['blocks'] = $this->request->post['XDCategoryGroupsBlocks'];
        } elseif ($this->config->get('XDCategoryGroupsBlocks')) { 
                $data['blocks'] = $this->config->get('XDCategoryGroupsBlocks');
        }

        //SAVE OR GET SETTINGS
        //SET DEFAULTS
        $data['XDSetting'] = array();
        $data['XDSetting']['categoryLimit'] = '5'; 
        $data['XDSetting']['blockHeight'] = '0'; 
        $data['XDSetting']['titlePosition'] = 'belowImage';         
        $data['XDSetting']['titleLinks'] = 'inactive';
        $data['XDSetting']['customCSSCode'] = '';
        $data['XDSetting']['blockPadding'] = '';
        $data['XDSetting']['blockPaddingLeft'] = '';
        $data['XDSetting']['blockPaddingRight'] = '';
        $data['XDSetting']['blockHeight'] = '';

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

        $this->load->model('design/layout');
        $data['layouts'] = $this->model_design_layout->getLayouts();

        $this->template = 'module/XDCategoryGroups.tpl';
       /* $this->children = array(
                'common/header',
                'common/footer'
        );*/
        $data['header'] = $this->load->controller('common/header');
        $data['column_left'] = $this->load->controller('common/column_left');
        $data['footer'] = $this->load->controller('common/footer');

       $this->response->setOutput($this->render(),$data);
    //$this->response->setOutput($this->load->view($template, $data));    
}

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

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

Open your index.php file in the root folder and add the following code at the very top :

// Enables PHP error reporting
error_reporting(E_ALL);
ini_set('display_errors', 'On');

This will enable full error reporting. AKA this will show the exact errors and the lines of code involved.

If, from there, you can't debug, give some feedback and make sure you include the error message(s).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM