简体   繁体   English

在OpenCart 2.0中安装重写的OpenCart 1.5模块时出现500 Internal Server Error

[英]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. 我需要在OpenCart 2上安装与OpenCart 1.5兼容的模块。安装成功,但是出现以下错误:间接修改OpenCart。 I tried to rewrite the code of the module in admin/controller/modules/mymodule.php . 我试图在admin/controller/modules/mymodule.php重写模块的代码。 After applying the following code I get Error 500 when try to edit module's settings. 应用以下代码后,尝试编辑模块的设置时出现错误500。 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 : 在根文件夹中打开index.php文件,并在最顶部添加以下代码:

// 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). 如果无法从那里进行调试,请提供一些反馈并确保您包含错误消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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