Jump to content

Add MANUFACTURER to mail alerts (new order)


mytheory.

Recommended Posts

Hi,

As the title suggests, how do I add the manufacturer name to the new order emails sent by the mailalerts module??

The new order email to the admin shows a list of the products' name but no manufacturer's names.

Here is the format I would like:

Manufacturer_Name - Product_name


Any advice is much appreciated!

Thanks!

Link to comment
Share on other sites

Hi,

Thanks for your response, but I am already aware of this. The code I used for older versions of PS does not work on v1.4.x.

And actually you do not need to edit the mail template... there is an array that is already passed to the mail alerts. This array is composed of all the product names and attributes for a particular order. I believe the array is called {items}

Anyways, how to do I add the manufacturer(s) to this array?

Thanks!

Link to comment
Share on other sites

Hi,

As I already mentioned... I already know this. I've already modified this to work on older versions of PS. Plus, the mail templates DO NOT need editing for this task. There is 1 array named {items} that essentially collects all the products from the order. Then on the mail template it outputs them according to the array.

You can see this by opening the new_order.html file and searching for {items}... then go to mailalerts.php and search for the same thing, here you will see the code for the array generating a list of the products from a particular order.

So, as I said before, I need help modifying the {items} array from mailalerts.php to include a manufacturer. I know I have to create another variable based on the Manufacturers class, but I think I am getting some of the parameters wrong (something must have changed in 1.4.x).

I will take another look at it... and then I will post what I already have once I find some more time today.

Thanks again for the input anyways!

Link to comment
Share on other sites

My assumptions are as followed based on what has been said so far.
1) you are using prestashop v1.4+
2) you are referring to the base module called 'mailalerts'
3) you are trying to add the product's manufacturer name to the new order template that is emailed to the admin, so the name appears before the product name.

If the above assumptions are correct you need to do the following...

edit the file called mailalerts.php located in the modules\mailalerts folder. in the function called hookNewOrder, you will see that a variable called itemsTable, and that contains the html that is used in the new order template {items}

you will see this line of code which creates the column for the product name.

'.$product['product_name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').'



you simply need to take the product_id, locate the manufacturer of that product, grabs its name and insert it before the product name as desired. Since you have already coded this is a prior version of prestashop, i'll assume you can code this.

Link to comment
Share on other sites

  • 1 year later...
  • 9 months later...

up 1.5

 

i have tried to modify method getProducts in MailAlert.php line n° 240  but not work. Please help me.

 * Get products according to alerts
	 */
	public static function getProducts($customer, $id_lang)
	{
		$sql = '
			SELECT ma.`id_product`, p.`quantity` AS product_quantity, pl.`name`, ma.`id_product_attribute`,  mf.`name` AS manufacturer_name
			FROM `'._DB_PREFIX_.self::$definition['table'].'` ma
			JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = ma.`id_product`)
			'.Shop::addSqlAssociation('product', 'p').'
			LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.id_shop IN ('.implode(', ', Shop::getContextListShopID(false)).'))
			LEFT JOIN `'._DB_PREFIX_.'manufacturer` mf ON (mf.`id_manufacturer` = p.`id_manufacturer`)			
				WHERE product_shop.`active` = 1
			AND (ma.`id_customer` = '.(int)$customer->id.' OR ma.`customer_email` = \''.pSQL($customer->email).'\')
			AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestriction(false, 'ma');
		
		print_r($sql); 
		return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
	}
Link to comment
Share on other sites

  • 3 years later...

The order details doesn't include the manufacturer name, so you will have to get it using the following code:

 

$manufacturer = new Manufacturer($product['id_manufacturer'], $id_lang);

 

Then you can use $manufacturer->name to write the manufacturer name in front of the product name.

 

Hello,where i have to add this code?

File?

Position?

 

Does it work in Prestashop 1.6.1.9??

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...