2017-02-16 4 views
2

在庫アラートのみを受信する受信者の特定のリストと、新しい注文アラートのみを受信する受信者のリストが必要です。Prestashop内のMailalertsモジュール受信者を分割する

どのような方法が最適ですか?

はここであなたに

enter image description here

+0

は、このコードでオーバーライドファイル/override/modules/mailalerts/mailalerts.phpを作成します。 ?このモジュールをオーバーライドし、データベースの新しいフィールドを追加して、アドレスの2番目のリストを格納する必要があります。また、在庫警告と注文警告を送信するコードを修正し、適切なフィールドを使用します。何を試しましたか?私たちは、あなたが行ったことを私たちに示してくれれば助けてくれるだけで、私たちはあなたのためにこの機能を開発するためのものではありません。 –

+0

あなたの答え@FlorianLemaitreに感謝します。 あなたの質問に答えるには:モジュールを複製してコードに変更しようとしました。モジュール1はOOSのみ、モジュール2はオーダーのみを送信します。 あなたのメッセージの最後について、私はそれが不愉快であると感じます。 私は人々に私のために機能を発達させるよう求めません。彼らがこのパズルにどう対処するかだけ。 私はPrestashopを初めて使い、効率的になりたいだけです。 とにかく助けてくれてありがとう – sullivanv

+0

ここでの問題は、多くの人が自分で答えを見つけようとせずに質問をすることです。私があなたの質問で読むことができるものから、あなたはすでに何かを試したことが分かりません。あなたが試したことをあなたの質問に追加しておくべきであり、これから正しい道を取っているかどうかを教えてもらえます。たとえあなたのコードがうまくいかず、あなたがそれを誇りに思っていないとしても、自分で何かを試したことを示す必要があります。さもなければ私達はあなたのために自由に働き、あなたを助けないという感情を持っています。 –

答えて

1

をありがとう、私はこの質問に対処する方法をある:あなたの問題は、正確に何

<?php 

class MailAlertsOverride extends MailAlerts 
{ 
    protected $merchant_mails_stock; 

    protected function init() 
    { 
     parent::init(); 
     $this->merchant_mails_stock = str_replace(',', self::__MA_MAIL_DELIMITOR__, (string)Configuration::get('MA_MERCHANT_MAILS_STOCK')); 
    } 

    public function install($delete_params = true) 
    { 
     if (! parent::install($delete_params)) 
      return false; 

     if ($delete_params) 
     { 
      Configuration::updateValue('MA_MERCHANT_MAILS_STOCK', Configuration::get('PS_SHOP_EMAIL')); 
     } 

     return true; 
    } 

    public function uninstall($delete_params = true) 
    { 
     if ($delete_params) 
     { 
      Configuration::deleteByName('MA_MERCHANT_MAILS_STOCK'); 
     } 

     return parent::uninstall(); 
    } 

    protected function postProcess() 
    { 
     $errors = array(); 

     if (Tools::isSubmit('submitMAMerchant')) 
     { 
      $emails = (string)Tools::getValue('MA_MERCHANT_MAILS_STOCK'); 

      if (!$emails || empty($emails)) 
       $errors[] = $this->l('Please type one (or more) e-mail address'); 
      else 
      { 
       $emails = str_replace(',', self::__MA_MAIL_DELIMITOR__, $emails); 
       $emails = explode(self::__MA_MAIL_DELIMITOR__, $emails); 
       foreach ($emails as $k => $email) 
       { 
        $email = trim($email); 
        if (!empty($email) && !Validate::isEmail($email)) 
        { 
         $errors[] = $this->l('Invalid e-mail:').' '.Tools::safeOutput($email); 
         break; 
        } 
        elseif (!empty($email) && count($email) > 0) 
         $emails[$k] = $email; 
        else 
         unset($emails[$k]); 
       } 

       $emails = implode(self::__MA_MAIL_DELIMITOR__, $emails); 

       if (!Configuration::updateValue('MA_MERCHANT_MAILS_STOCK', (string)$emails)) 
        $errors[] = $this->l('Cannot update settings'); 
      } 
     } 

     if (count($errors) > 0) 
     { 
      $this->html .= $this->displayError(implode('<br />', $errors)); 
      return $this->init(); 
     } 

     parent::postProcess(); 
    } 

    public function hookActionUpdateQuantity($params) 
    { 
     $this->merchant_mails = $this->merchant_mails_stock; 
     parent::hookActionUpdateQuantity($params); 
    } 

    public function renderForm() 
    { 
     $fields_form_1 = array(
      'form' => array(
       'legend' => array(
        'title' => $this->l('Customer notifications'), 
        'icon' => 'icon-cogs' 
       ), 
       'input' => array(
        array(
         'type' => 'switch', 
         'is_bool' => true, //retro compat 1.5 
         'label' => $this->l('Product availability'), 
         'name' => 'MA_CUSTOMER_QTY', 
         'desc' => $this->l('Gives the customer the option of receiving a notification when an out-of-stock product is available again.'), 
         'values' => array(
          array(
           'id' => 'active_on', 
           'value' => 1, 
           'label' => $this->l('Enabled') 
          ), 
          array(
           'id' => 'active_off', 
           'value' => 0, 
           'label' => $this->l('Disabled') 
          ) 
         ), 
        ), 
        array(
         'type' => 'switch', 
         'is_bool' => true, //retro compat 1.5 
         'label' => $this->l('Order edit'), 
         'name' => 'MA_ORDER_EDIT', 
         'desc' => $this->l('Send a notification to the customer when an order is edited.'), 
         'values' => array(
          array(
           'id' => 'active_on', 
           'value' => 1, 
           'label' => $this->l('Enabled') 
          ), 
          array(
           'id' => 'active_off', 
           'value' => 0, 
           'label' => $this->l('Disabled') 
          ) 
         ), 
        ), 
       ), 
       'submit' => array(
        'title' => $this->l('Save'), 
        'class' => 'btn btn-default pull-right', 
        'name' => 'submitMailAlert', 
       ) 
      ), 
     ); 

     $fields_form_2 = array(
      'form' => array(
       'legend' => array(
        'title' => $this->l('Merchant notifications'), 
        'icon' => 'icon-cogs' 
       ), 
       'input' => array(
        array(
         'type' => 'switch', 
         'is_bool' => true, //retro compat 1.5 
         'label' => $this->l('New order'), 
         'name' => 'MA_MERCHANT_ORDER', 
         'desc' => $this->l('Receive a notification when an order is placed.'), 
         'values' => array(
          array(
           'id' => 'active_on', 
           'value' => 1, 
           'label' => $this->l('Enabled') 
          ), 
          array(
           'id' => 'active_off', 
           'value' => 0, 
           'label' => $this->l('Disabled') 
          ) 
         ), 
        ), 
        array(
         'type' => 'switch', 
         'is_bool' => true, //retro compat 1.5 
         'label' => $this->l('Out of stock'), 
         'name' => 'MA_MERCHANT_OOS', 
         'desc' => $this->l('Receive a notification if the available quantity of a product is below the following threshold.'), 
         'values' => array(
          array(
           'id' => 'active_on', 
           'value' => 1, 
           'label' => $this->l('Enabled') 
          ), 
          array(
           'id' => 'active_off', 
           'value' => 0, 
           'label' => $this->l('Disabled') 
          ) 
         ), 
        ), 
        array(
         'type' => 'text', 
         'label' => $this->l('Threshold'), 
         'name' => 'MA_LAST_QTIES', 
         'class' => 'fixed-width-xs', 
         'desc' => $this->l('Quantity for which a product is considered out of stock.'), 
        ), 
        array(
         'type' => 'switch', 
         'is_bool' => true, //retro compat 1.5 
         'label' => $this->l('Coverage warning'), 
         'name' => 'MA_MERCHANT_COVERAGE', 
         'desc' => $this->l('Receive a notification when a product has insufficient coverage.'), 
         'values' => array(
          array(
           'id' => 'active_on', 
           'value' => 1, 
           'label' => $this->l('Enabled') 
          ), 
          array(
           'id' => 'active_off', 
           'value' => 0, 
           'label' => $this->l('Disabled') 
          ) 
         ), 
        ), 
        array(
         'type' => 'text', 
         'label' => $this->l('Coverage'), 
         'name' => 'MA_PRODUCT_COVERAGE', 
         'class' => 'fixed-width-xs', 
         'desc' => $this->l('Stock coverage, in days. Also, the stock coverage of a given product will be calculated based on this number.'), 
        ), 
        array(
         'type' => 'switch', 
         'is_bool' => true, //retro compat 1.5 
         'label' => $this->l('Returns'), 
         'name' => 'MA_RETURN_SLIP', 
         'desc' => $this->l('Receive a notification when a customer requests a merchandise return.'), 
         'values' => array(
          array(
           'id' => 'active_on', 
           'value' => 1, 
           'label' => $this->l('Enabled') 
          ), 
          array(
           'id' => 'active_off', 
           'value' => 0, 
           'label' => $this->l('Disabled') 
          ) 
         ), 
        ), 
        array(
         'type' => 'textarea', 
         'cols' => 36, 
         'rows' => 4, 
         'label' => $this->l('E-mail addresses'), 
         'name' => 'MA_MERCHANT_MAILS', 
         'desc' => $this->l('One e-mail address per line (e.g. [email protected]).'), 
        ), 
        array(
         'type' => 'textarea', 
         'cols' => 36, 
         'rows' => 4, 
         'label' => $this->l('E-mail stock addresses'), 
         'name' => 'MA_MERCHANT_MAILS_STOCK', 
         'desc' => $this->l('One e-mail address per line (e.g. [email protected]).'), 
        ), 
       ), 
       'submit' => array(
        'title' => $this->l('Save'), 
        'class' => 'btn btn-default pull-right', 
        'name' => 'submitMAMerchant', 
       ) 
      ), 
     ); 

     $helper = new HelperForm(); 
     $helper->show_toolbar = false; 
     $helper->table = $this->table; 
     $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); 
     $helper->default_form_language = $lang->id; 
     $helper->module = $this; 
     $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; 
     $helper->identifier = $this->identifier; 
     $helper->submit_action = 'submitMailAlertConfiguration'; 
     $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->getConfigFieldsValues(), 
      'languages' => $this->context->controller->getLanguages(), 
      'id_language' => $this->context->language->id 
     ); 

     return $helper->generateForm(array($fields_form_1, $fields_form_2)); 
    } 

    public function getConfigFieldsValues() 
    { 
     $config = parent::getConfigFieldsValues(); 
     $config['MA_MERCHANT_MAILS_STOCK'] = Tools::getValue('MA_MERCHANT_MAILS_STOCK', Configuration::get('MA_MERCHANT_MAILS_STOCK')); 
     return $config; 
    } 
} 
+0

このコードはテストされていませんが、全体的な概念はここにあります。あなたの特別なニーズにそれを適応させるべきです。 –

関連する問題