2017-03-10 5 views
0

Prestashop Mail을 사용하려고합니다 :: 외부 PHP 파일 (API 엔드 포인트)로 보내기 try.ied는 config.inc.php, init.php도 포함합니다. PHP 메일 기능을 사용하는 API처럼 보입니다. 그러나 Presta에는 Mail 클래스가 있고 다른 Prestashop 클래스는 올바르게 작동합니다. 나는 코드가 PrestaShop 버전 1.6.1.9 및 PHP 5.6prestashop Mail :: :: 외부 PHP 파일로 보내기

있습니다

class VoucherModel extends baseModel{ 

// Other methods 
public function addSubscriber($email) 
{ 
    $result = Db::getInstance()->insert("mail_subscribers", array(
     "email" => pSQL($email) 
    )); 

    if($result){ 

     $cartRule = "XYZ123"; 
     $sendMail = $this->_sendMail($email, $cartRule); 

     return $sendMail; 
    } 
} 

public function _sendMail($email, $code = "LOVEMANA") 
{ 
    $templateVars['{code}'] = $code; 
    $id_land = Language::getIdByIso('cs'); 
    $template_name = 'sendvoucher'; 
    $title = 'Váše kredity'; 
    $from = Configuration::get('PS_SHOP_EMAIL'); 
    $fromName = Configuration::get('PS_SHOP_NAME'); 
    $mailDir = _PS_THEME_DIR_.'/mails/'; 

    return Mail::Send($id_land, $template_name, $title, $templateVars, $email, "", $from, $fromName); 

} 
} 

을하지만 난 오류가 점점 :

Got error 'PHP message: PHP Deprecated: Non-static method Mail::send() should not be called statically, assuming $this from incompatible context in /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/models/prestashop.php on line 780 
PHP message: PHP Stack trace: 
PHP message: PHP 1. {main}() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/index.php:0 
PHP message: PHP 2. Luracast\\Restler\\Restler->handle() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/index.php:41 
PHP message: PHP 3. Luracast\\Restler\\Restler->call() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:283 
PHP message: PHP 4. call_user_func_array:{/home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989}() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989 
PHP message: PHP 5. v1\\Api->subscribe() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989 
PHP message: PHP 6. prestashop->addSubscriber() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/v1/Api.php:1090 
PHP message: PHP 7. prestashop->_sendMail() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/models/prestashop.php:764 

PHP message: PHP Deprecated: Non-static method PEAR::raiseError() should not be called statically, assuming $this from incompatible context in /usr/share/php/Mail.php on line 117 
PHP message: PHP Stack trace: 
PHP message: PHP 1. {main}() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/index.php:0 
PHP message: PHP 2. Luracast\\Restler\\Restler->handle() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/index.php:41 
PHP message: PHP 3. Luracast\\Restler\\Restler->call() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:283 
PHP message: PHP 4. call_user_func_array:{/home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989}() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989 
PHP message: PHP 5. v1\\Api->subscribe() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/include/Luracast/Restler/Restler.php:989 
PHP message: PHP 6. prestashop->addSubscriber() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/v1/Api.php:1090 
PHP message: PHP 7. prestashop->_sendMail() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/models/prestashop.php:764 
PHP message: PHP 8. Mail->send() /home/97569-75425.cloudwaysapps.com/axbxzqwhfd/public_html/obchod/mobileapiv2/models/prestashop.php:780 
', referer: https://beta.drink-mana.com/en/ 

기타 PrestaShop 버전의 클래스가 제대로 작동합니다. (Configuration :: get, Product :: getPriceStatic)

답변

0

이 메서드는 통계적이지 않은 메서드를 호출하십시오.

이 코드를 사용하려고 5.4+ PHP가있는 경우 :

return (new Mail)->Send($id_land, $template_name, $title, $templateVars, $email, "", $from, $fromName); 

또는 유 PHP < 5.4이있는 경우,이 시도 :

$mail = new Mail(); 
return $mail->Send($id_land, $template_name, $title, $templateVars, $email, "", $from, $fromName); 
+0

아무것도 여전히 점점 : 사용되지 않는 : 비 정적 PEAR :: raiseError()는 라인 117의 /usr/share/php/Mail.php에있는 호환되지 않는 컨텍스트에서 $ this를 가정하여 정적으로 호출해서는 안됩니다 –

+0

이 오류를 제거하려면/usr/share/php/Mail.php를 수정하고 PEAR :: raiseError를 (new PEAR) -> raiseError로 바꿉니다. 나는 shure 아니지만 도움이됩니다. –

+0

이 작업을 수행 할 수있는 권한이 없습니다. –

관련 문제