rylook Posted December 6, 2013 Share Posted December 6, 2013 (edited) Bonjour, Je commence mes premiers dev sur Presta et j'aimerais envoyer un mail avec la configuration smtp qui est active et qui fonctionne déjà en back office, je trouve pas comment faire çà. Le module Alerte mail envoi bien les messages avec smtp, le message test aussi part bien. Mais j'aimerais savoir comment utiliser l'envoi des mails simplement à l'intérieur d'une méthode écrite dans un controller que j'ai surchargé. ci-dessous (public function hookActionUpdateQuantity($params)), c'est la méthode du mail que j'aimerais dupliquer : dans modules/mailalerts/mailalerts.php Merci pour vos réponses, si quelqu'un à déjà voulu envoyer des mails depuis une classe personnelle et voudrait bien m'expliquer comment envoyer des mails car là je bloque depuis un moment... public function hookActionUpdateQuantity($params) { $id_product = (int)$params['id_product']; $product = new Product($id_product); $product_has_attributes = $product->hasAttributes(); $id_product_attribute = (int)$params['id_product_attribute']; $quantity = (int)$params['quantity']; $context = Context::getContext(); $id_shop = (int)$context->shop->id; $id_lang = (int)$context->language->id; $product = new Product($id_product, true, $id_lang, $id_shop, $context); $configuration = Configuration::getMultiple(array('MA_LAST_QTIES', 'PS_STOCK_MANAGEMENT', 'PS_SHOP_EMAIL', 'PS_SHOP_NAME'), null, null, $id_shop); $ma_last_qties = (int)$configuration['MA_LAST_QTIES']; $check_oos = ($product_has_attributes && $id_product_attribute) || (!$product_has_attributes && !$id_product_attribute); if ($check_oos && $product->active == 1 && (int)$quantity <= $ma_last_qties && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && $configuration['PS_STOCK_MANAGEMENT']) { $iso = Language::getIsoById($id_lang); $product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang); $template_vars = array( '{qty}' => $quantity, '{last_qty}' => $ma_last_qties, '{product}' => $product_name ); if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.txt') && file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.html')) { // Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients $merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails); foreach ($merchant_mails as $merchant_mail) { Mail::Send( $id_lang, 'productoutofstock', Mail::l('Product out of stock', $id_lang), $template_vars, $merchant_mail, null, strval($configuration['PS_SHOP_EMAIL']), strval($configuration['PS_SHOP_NAME']), null, null, dirname(__FILE__).'/mails/', false, $id_shop ); } } } if ($this->_customer_qty && $quantity > 0) MailAlert::sendCustomerAlert((int)$product->id, (int)$params['id_product_attribute']); } Edited December 6, 2013 by rylook (see edit history) Link to comment Share on other sites More sharing options...
rylook Posted December 6, 2013 Author Share Posted December 6, 2013 Please Help! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now