私はPrestaShop 1.6モジュールを作っていて、変なことが起こっています。このモジュールのconfigureページでは、ユーザーに2つのフォームを提供します。 1つは自動電子メールを構成し、その他は電子メールをテストするものです。ライン90で
Fatal error: Call to a member function assign() on null in /Users/andre/Projects/Web/xxx/modules/closecustomerthreademail/closecustomerthreademail.php on line 90
私が持っている:私の問題は、私は、このエラーを与えて$this->context->smarty
がnullである第二のフォームを提出した後ということで、この関数の内部にある$this->context->smarty->assign('module_dir', $this->_path);
:
public function getContent()
{
/**
* If values have been submitted in the form, process.
*/
if (((bool)Tools::isSubmit('submitClosecustomerthreademailModule')) == true) {
$this->postProcess();
}
$this->context->smarty->assign('module_dir', $this->_path);
$output = $this->context->smarty->fetch($this->local_path.'views/templates/admin/configure.tpl');
return $output.$this->renderForm();
}
これはどのようにあるI画面に2つのフォームを追加します(renderFormメソッド)。return $helper->generateForm(array($this->getConfigForm(), $this->getTestForm()));
ポストプロセスです。たくさんのコードを貼り付けて申し訳ありませんが、関連性のあるすべての詳細を提供しようとしています。
protected function postProcess()
{
if(Tools::isSubmit('test_form')) {
$this->sendTestEmailTo(Tools::getValue('CLOSECUSTOMERTHREADEMAIL_EMAIL_TO_TEST'));
}
elseif(Tools::isSubmit('config_form')) {
$form_values = $this->getConfigFormValues('config_form');
foreach (array_keys($form_values) as $key) {
Configuration::updateValue($key, Tools::getValue($key));
}
}
}
sendTestEmailTo
ちょうどこの関数を呼び出し、その後IF文を持っていると:
public function sendEmail($to_email, $to_name = null){
$id_lang = $this->context->language->id;
$template_dir = _PS_MODULE_DIR_.$this->name.'/views/templates/email/';
$vars = array(
'{html}' => Configuration::get('CLOSECUSTOMERTHREADEMAIL_EMAIL_HTML_BODY'),
'{text}' => Configuration::get('CLOSECUSTOMERTHREADEMAIL_EMAIL_TEXT_BODY')
);
require(_PS_CONFIG_DIR_.'config.inc.php');
require_once(_PS_ROOT_DIR_.'/init.php');
$send = Mail::Send(
(int)$id_lang,
'email',
Configuration::get('CLOSECUSTOMERTHREADEMAIL_EMAIL_SUBJECT'),
$vars,
$to_email,
$to_name,
null,
null,
null,
null,
$template_dir,
false,
(int)$this->context->shop->id,
null
);
return $send;
}
私は$this->context->smarty
はnull
であることを引き起こしている可能性がものを見るために失敗しています。調査を手助けするヒントはありますか?私は、解決するためにリダイレクトをこれをしなければならなかったので、私は出荷前に把握することができませんでし
public function __construct()
{
$this->name = 'closecustomerthreademail';
$this->tab = 'others';
$this->version = '1.0.0';
$this->author = 'andre';
$this->need_instance = 0;
/**
* Set $this->bootstrap to true if your module is compliant with bootstrap (PrestaShop 1.6)
*/
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Close Customer Thread e-mail');
$this->description = $this->l('Sends an e-mail whenever you close a customer thread');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall this module?');
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
}
__constructメソッドを投稿できますか?ありがとう:) – sarcom
@サルコムちょうど、ありがとう –