Jump to content

Edit MailAlert module to send mails to Manufacturers


Agilulfo

Recommended Posts

Hello to all, I know there are plenty of threads discussing about this but they are all old and on meny of them are empty...so I decided to start a new one.

 

Right now I'm editing mailalerts.php to send the mail also to the manufacturer of the product. 

I found the function that is sending e-mails (for exemple public function hookActionValidateOrder($params) ).

Right now  I can send a mail to a certain manufacture e-mail if I staticaly define my variable, like this:

$manufacturer_mail="[email protected]";
    
    Mail::Send(
    $mail_id_lang,
    'new_order',
    sprintf(Mail::l('New order : #%d - %s', $mail_id_lang), $order->id, $order->reference),
    $template_vars,
    $manufacturer_mail,
    null,
    $configuration['PS_SHOP_EMAIL'],
    $configuration['PS_SHOP_NAME'],
    null,
    null,
    $dir_mail,
    null,
    $id_shop
    );

My problem is that I don't know how to take the product_id and use it to firstly take the manufacturer_id associated with that product and finaly the manufacturer_mail (I insert the mail in the "name" field in db instead of creating a custom field).

 

I was thinking to using something like this to take the manufacturer mail, but I need the $id_product...

$id_manufacturer= Db::getInstance()->executeS('SELECT `id_manufacturer` FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)$id_product);
$manufacturer_mail=Db::getInstance()->executeS('SELECT `name` FROM `nnw5_manufacturer` WHERE `id_manufacturer` = '.(int)$id_manufacturer);

Do you have any idea on how to do it?

 

 

Original files attached.

 

Edit: See solution here: https://www.prestashop.com/forums/topic/548021-send-email-to-the-products-manufacturer-or-supplier-only-not-all-merchants/?p=2524217

MailAlert.php

mailalerts.php

Edited by Agilulfo (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...