Jump to content

Mailalerts outofstock mail won't load product attributes


Recommended Posts

I'm going a little bit mad with this. I updated the shop to 1.4.11 and now, anytime a product stock goes below threshold the mail sent by mailalerts module doesn't show the product combination if it has one. Indeed it seem to calculate total product stock instead of the particular combination affected.

 

I understand this is the code I have to struggle with, but I don't have a clue on how to debug it further (I assume $params['product']['attributes_small'] is the core of my problem, but don't know where to follow it to catch the bug):

 

public function hookUpdateQuantity($params)
{
 global $cookie;
 if (is_object($params['product']))
  $params['product'] = get_object_vars($params['product']);
 if (is_array($params['product']['name']))
  $params['product']['name'] = $params['product']['name'][(int)Configuration::get('PS_LANG_DEFAULT')];
 if (isset($params['product']['id_product']))
  $params['product']['id'] = (int)$params['product']['id_product'];
 $qty = (int)$params['product']['quantity'];
 if ($qty <= (int)Configuration::get('MA_LAST_QTIES') && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && Configuration::get('PS_STOCK_MANAGEMENT'))
 {
  $templateVars = array(
'{qty}' => $qty,
'{last_qty}' => (int)(Configuration::get('MA_LAST_QTIES')),
'{product}' => strval($params['product']['name']).(isset($params['product']['attributes_small']) ? ' '.$params['product']['attributes_small'] : ''));
  $id_lang = (is_object($cookie) && isset($cookie->id_lang)) ? (int)$cookie->id_lang : (int)Configuration::get('PS_LANG_DEFAULT');
  $iso = Language::getIsoById((int)$id_lang);

  if ($params['product']['active'] == 1)
  {
if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.txt') && file_exists(dirname(__FILE__).'/mails/'.$iso.'/productoutofstock.html'))
 Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'productoutofstock', Mail::l('Product out of stock', (int)Configuration::get('PS_LANG_DEFAULT')), $templateVars, explode(self::__MA_MAIL_DELIMITOR__, $this->_merchant_mails), null, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), null, null, dirname(__FILE__).'/mails/');
  }
 }
 if ($this->_customer_qty && $params['product']['quantity'] > 0)
  $this->sendCustomerAlert((int)$params['product']['id'], 0);
}

Link to comment
Share on other sites

×
×
  • Create New...