0

安装 prestashop 自定义模块后出现致命错误:单击由模块创建的菜单时调用未定义方法致命错误:调用 D:\xampp\htdocs\raffleV1.3\oknr9hexztcseff5\ 中的未定义方法 querydr::viewAccess()第 279 行的functions.php

<?php
if (!defined('_PS_VERSION_')) exit;
class querydr extends Module
{

protected $config_form = false;
public $html;
public $tabName = 'renderForm';
public function __construct()
{

    $this->name = 'querydr';
    $this->tab = 'others';
    $this->version = '1.0.0';
    $this->author = 'xyz';
    $this->need_instance = 1;
    $this->module_key = 'f35950b303e7cbcda7fd8e56bb100d77121';
    /**
     * Set $this->bootstrap to true if your module is compliant with bootstrap (PrestaShop 1.6)
     */
    $this->bootstrap = true;
    parent::__construct();
    $this->displayName = $this->l('Query DR');
    $this->description = $this->l('Allow your Back Office to Query the transactions ');
    $this->confirmUninstall = $this->l('You want to Uninstall Query DR ?.');
    $this->_tabsArray = array(
    'Querydr' => 'Query DR',  
    );

    if (!Configuration::get('QUERYDR'))
        $this->warning = $this->l('No name provided');
}





/**
 * Don't forget to create update methods if needed:
 * http://doc.prestashop.com/display/PS16/Enabling+the+Auto-Update
 */
public function install()
{
    include(dirname(__FILE__).'/sql/install.php');

    return parent::install()  &&
        Configuration::updateValue('QUERYDR','Query Dr')
        && $this->_installTabs();
}

private function _installTabs()
{
    $parentTab = new Tab();
    foreach (Language::getLanguages() as $language) $parentTab->name[$language['id_lang']] = 'Query Dr';
    $parentTab->class_name = 'Querydr';
    $parentTab->module = $this->name;
    $parentTab->id_parent = 0;
    if (!$parentTab->save()) return false;
    else {
        $idTab = $parentTab->id;
        //$idEn = Language::getIdByIso('en');
        foreach ($this->_tabsArray as $tabKey => $name) {
            $childTab = new Tab();
            foreach (Language::getLanguages() as $language) $childTab->name[$language['id_lang']] = $name;

            $childTab->class_name = $tabKey;
            $childTab->module = $this->name;
            $childTab->id_parent = $idTab;

            if (!$childTab->save()) return false;
        }
    }
    return true;
}



public function uninstall()
{
    include(dirname(__FILE__).'/sql/uninstall.php');
    Configuration::deleteByName('QUERYDR');
    Configuration::deleteByName('QUERYDR_MERCHANT_ID');
    Configuration::deleteByName('QUERYDR_SECRET_KEY');
    $this->_uninstallTabs();
     if (!parent::uninstall())
    return false;
  return true;

}


private function _uninstallTabs()
{
    foreach ($this->_tabsArray as $tabKey => $name) {
        $idTab = Tab::getIdFromClassName($tabKey);
        if ($idTab != 0) {
            $tab = new Tab($idTab);
            $tab->delete();
        }
    }

    $idTab = Tab::getIdFromClassName('QueryDr');
    if ($idTab != 0) {
        $tab = new Tab($idTab);
        $tab->delete();
    }
    return true;
}


   public function getContent()
{
    if (Tools::isSubmit('submitQueryDrModule')) {
        Configuration::updateValue('QUERYDR_MERCHANT_ID', Tools::getValue('QUERYDR_MERCHANT_ID'));
        Configuration::updateValue('QUERYDR_SECRET_KEY', Tools::getValue('QUERYDR_SECRET_KEY'));
        $this->html .= $this->displayConfirmation($this->l('Settings Updated'));
        $this->tabName = 'renderForm';
    } 

    if ($this->tabName) {
        $this->html .= '<script>$(document).ready(function(){$("#'.$this->tabName.'").addClass("active");$(".'.$this->tabName.'").parents(".nav-tabs > li").addClass("active");});</script>';
    } else {
        $this->html .= '<script>$(document).ready(function(){$("#renderForm").addClass("active");                    $(this).attr("href").indexOf("#renderForm").addClass("active");});</script>';
    }
    $this->html .= '<ul class="nav nav-tabs" role="tablist"><li ><a class="renderForm" href="#renderForm" role="tab" data-toggle="tab">SETTINGS</a></li></ul>';

    $this->html .= '<div class="tab-content"><div class="tab-pane " id="renderForm">'.$this->renderForm_1_6().'</div></div>';
    $this->html .='<style>div.flash.fail {color: #cd0a0a;background-color: #fef1ec;border: #cd0a0a 1px solid;                            padding: 0.5em;margin: 0 3px;margin-top: 22px;margin-bottom: 12px;text-align: center;border-radius: 2px 2px 2px 2px;}</style>';

    return $this->html;
}

  protected function renderForm_1_6()
{
    $fields_form = array(
                        'form' => array(
                            'legend' => array(
                                            'title' => $this->l('Settings'),
                                            'icon' => 'icon-cogs',
                                        ),
                            'input' => array(
                                                  array(
                                    'col' => 3,
                                    'type' => 'text',
                                    'desc' => $this->l('Your merchant ID ex: 201408191000001'),
                                    'name' => 'QUERYDR_MERCHANT_ID',
                                    'label' => $this->l('MERCHANT ID'),
                                ),                     array(
                                    'col' => 3,
                                    'type' => 'text',
                                    'desc' => $this->l('Your key provided by network international'),
                                    'name' => 'QUERYDR_SECRET_KEY',
                                    'label' => $this->l('SECRET KEY'),
                                )
                                        ),
                                        'submit' => array(
                                                        'title' => $this->l('Save'),
                                                    ),
                                    )
                        );

    $helper = new HelperForm();
    $helper->show_toolbar = false;
    $helper->table = $this->table;
    $helper->module = $this;
    $helper->default_form_language = $this->context->language->id;
    $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0);
    $helper->identifier = $this->identifier;
    $helper->submit_action = 'submitQueryDrModule';
    $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false)
    .'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
    $helper->token = Tools::getAdminTokenLite('AdminModules');

    $helper->tpl_vars = array(
    'fields_value' => $this->getConfigFormValues(), /* Add values for your inputs */
    'languages' => $this->context->controller->getLanguages(),
    'id_language' => $this->context->language->id,
    );

    return $helper->generateForm(array(
    $fields_form));
}

    protected function getConfigFormValues()
{
    return array(
        'QUERYDR_MERCHANT_ID' => Configuration::get('QUERYDR_MERCHANT_ID'),
        'QUERYDR_SECRET_KEY'  => Configuration::get('QUERYDR_SECRET_KEY'),
    );
}   

}

我的模块链接在这里——

https://www.dropbox.com/s/juyhcu5zub8p9fi/querydr.zip?dl=0

4

1 回答 1

0

我不确定它是否会对您有所帮助,但是...尝试在您的管理控制器名称前加上“Admin”,如“AdminQuerydrController”,并在您的选项卡安装中更改它

tab->class_name = 'AdminQuerydrController';

确保也更改您的控制器 php 文件名

“AdminQuerydrController.php”

于 2016-09-16T18:32:24.533 回答