Jump to content

Mailalert and image product


Recommended Posts

Not without modifying the Mail Alerts module. You'd have to find the template variables on line 182 of modules/mailalerts/MailAlert.php:

			$template_vars = array(
				'{product}' => (is_array($product->name) ? $product->name[$id_lang] : $product->name),
				'{product_link}' => $product_link
			);

And change it to something like:

			$id_image = 0;
			$result = Product::getCoverImage((int)$product->id);
            
			if (is_array($result) && isset($result['id_image'])) {
				$id_image = (Configuration::get('PS_LEGACY_IMAGES') ? $product->id.'-' : '').(int)$result['id_image'];
			} else {
				$id_image = $this->context->language->iso_code.'-default';   
			}
            
			$template_vars = array(
				'{product}' => (is_array($product->name) ? $product->name[$id_lang] : $product->name),
				'{product_link}' => $product_link,
				'{product_image_link}' => $link->getImageLink($product->link_rewrite, $id_image, 'small_default')
			);

I haven't tested this code, but it should get the product image link in the 'small_default' size of 80x80 pixel and put it in the {product_image_link} variable. You can then use that in modules/mailalerts/mails/en/customer_qty.html like this:

<img src="{product_image_link}" alt="{product}" width="80" height="80" />

Hopefully, this will point you in the right direction.

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

Hello rocky,

i just tried doing the same on PS 1.6.1.10 with multistore enabled and MailAlerts module 3.2.9 but there's something wrong.

 

When I apply the modify the MailAlert module stop working, and when increa the quantity of a product from BO rpoduct detail instead of showeing the green confirmation popup if show a red message: "error: Internal Server Error". I think because there's something wrong with the module, so it's not able to send the email.

Link to comment
Share on other sites

  • 2 months later...

Hi there,

 

I think i figured it out for 1.6.1.13. 

 

I'm not php developer. There might be problem on code quality but its working  :)

            $image_url = '';
            $image = Product::getCover((int)$id_product);
            if (sizeof($image) > 0)
            {
                $image_type = 'large_default';
                $image_url = $context->link->getImageLink($product->link_rewrite, $id_product.'-'.$image['id_image'], $image_type);
            }
			$template_vars = array(
				'{product}' => (is_array($product->name) ? $product->name[$id_lang] : $product->name),
				'{product_link}' => $product_link,
				'{image_url}' => $image_url
			);
Edited by originmad (see edit history)
Link to comment
Share on other sites

  • 8 months later...
  • 1 year later...

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