News:

Support the VirtueMart project and become a member

Main Menu

Low stock notification mail

Started by dcsupp, December 20, 2013, 14:55:47 PM

Previous topic - Next topic

dcsupp

Hey all ,
I am trying to change the low stock notification e-mail template.

I want to display the sku instead of the product name in the mail body.

I have found the file (/public_html/administrator/components/com_virtuemart/models/product.php) to make the change but nothing seems to happen.

Line ~ 2291

/* Load the product details */
$q = "SELECT l.product_name,product_in_stock FROM `#__virtuemart_products_" . VMLANG . "` l
JOIN `#__virtuemart_products` p ON p.virtuemart_product_id=l.virtuemart_product_id
   WHERE p.virtuemart_product_id = " . $virtuemart_product_id;
   
$this->_db->setQuery ($q);
$vars = $this->_db->loadAssoc ();

$url = JURI::root () . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id;
$link = '<a href="'. $url.'">'. $vars['product_name,product_sku'].'</a>';
$vars['subject'] = JText::sprintf('COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_SUBJECT',$vars['product_name,product_sku']);
$vars['mailbody'] =JText::sprintf('COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_BODY',$link, $vars['product_in_stock']);


I've changed the "product_name" with "product_sku" but nothing !

Your help and ideas are more than welcome !
Joomla 2.5.16 / Virtuemart  2.0.22a

mbarry

Hi dcsupp,
Just finished investigating this one myself. Here is what I did to get it to work for me.

- Modifying the Code
Your identified code fragment is the right area however, you made a couple of mistakes.
1. First up you need to SELECT the product_sku from the table #__virtuemart_products. Add product_sku to the SELECT
2. $vars['<some_item>'] you can only index a single item ie. $vars['product_sku'] or $vars['product_name'] not both.
3. changed $link to include only the $vars['product_sku']

To test it.
Find a test order that is known to have a product that will trigger the low stock notification
Set the Order status back to Confirmed and then forward to Shipped


/* Load the product details */
$q = "SELECT l.product_name,product_in_stock, product_sku FROM `#__virtuemart_products_" . VMLANG . "` l
JOIN `#__virtuemart_products` p ON p.virtuemart_product_id=l.virtuemart_product_id
   WHERE p.virtuemart_product_id = " . $virtuemart_product_id;
   
$this->_db->setQuery ($q);
$vars = $this->_db->loadAssoc ();

$url = JURI::root () . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id;
$link = '<a href="'. $url.'">'. $vars['product_sku'].'</a>';
$vars['subject'] = JText::sprintf('COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_SUBJECT',$vars['product_name']);
$vars['mailbody'] =JText::sprintf('COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_BODY',$link, $vars['product_in_stock']);



Note: if you want to change the email subject line as well

$q = "SELECT l.product_name,product_in_stock,product_sku FROM `#__virtuemart_products_" . VMLANG . "` l
JOIN `#__virtuemart_products` p ON p.virtuemart_product_id=l.virtuemart_product_id
   WHERE p.virtuemart_product_id = " . $virtuemart_product_id;
$this->_db->setQuery ($q);
$vars = $this->_db->loadAssoc ();

$url = JURI::root () . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id;
$link = '<a href="'. $url.'">'. $vars['product_sku'].'</a>';

$subjectLine = $vars['product_name']." (sku ".$vars['product_sku'].") ";
$vars['subject'] = JText::sprintf('COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_SUBJECT',$subjectLine);
$vars['mailbody'] =JText::sprintf('COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_BODY',$link, $vars['product_in_stock']);