Jump to content

Customer Mail Alert Issue


rseigel

Recommended Posts

Sorry for the double post but I thought this topic might more action here. :D

 

I have a simple script I use to update the quantities (from a dropshipper).

 

It works fine but when a product goes from 0 to "something more than 0" Presta doesn't send the "Back in Stock" email to customers (I've tested this myself and it just doesn't work).

 

Is there something I can do to force it to either fire the required code already built in or something I can add to make it happen outside of Presta?

 

Here's the code (feel free to offer any suggestions to make it more efficient as well):

 

$row = 0;
$update_table = "product";
$update_table_2 = "product_attribute";
$handle = fopen("GeneratedList.csv", "r+");
while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
   $num = count($data);
   $row++;
   for ($c=0; $c < $num; $c++) {
    if ($c = 1) {
  $supplier_reference = $data[($c-1)];
 }
    if ($c = 2) {
  $quantity = $data[($c-1)];
  mysql_query("UPDATE $update_table SET quantity='$quantity' WHERE supplier_reference='$supplier_reference'");
  mysql_query("UPDATE $update_table_2 SET quantity='$quantity' WHERE supplier_reference='$supplier_reference'")
  or die(mysql_error());
    }
   }
}
fclose($handle);
echo "  -  -  -  B&F INVENTORY UPDATE SUCESSFULY COMPLETED  -  -  -  ";

 

 

TIA!

Link to comment
Share on other sites

Hi! I cannot be sure, but if you don't have other options, try a web service to test your e-mail settings. I'm using Shopping Cart Diagnostics, they're fast and offer a great number of different checks. I think, it could help to discover what went wrong. This article will give you an insight in what it is about.

Link to comment
Share on other sites

Ok....it looks to me that they key is in /modules/mailalerts/mailalerts.php.

 

I believe the following two functions need to be fired to make this work:

 

public static function getProductsAlerts($id_customer, $id_lang)

 

and

 

private function _postProcess()

 

Does anyone know if I'm on the right path here?

 

Any and all help as to how to make this work would be amazing. :D

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

This is the hook that makes sense to me:

 

Product attribute update - 1 module (Technical name: updateProductAttribute)

 

That leads you to this in /classes/product.php

 

public function updateProductAttribute($id_product_attribute, $wholesale_price, $price, $weight, $unit, $ecotax, $quantity, $id_images, $reference, $supplier_reference, $ean13, $default, $location = NULL, $upc = NULL, $minimal_quantity)
{
 Db::getInstance()->Execute('
 DELETE FROM `'._DB_PREFIX_.'product_attribute_combination`
 WHERE `id_product_attribute` = '.(int)($id_product_attribute));
 $price = str_replace(',', '.', $price);
 $weight = str_replace(',', '.', $weight);
 $data = array(
 'wholesale_price' => (float)($wholesale_price),
 'price' => (float)($price),
 'ecotax' => (float)($ecotax),
 'weight' => ($weight ? (float)($weight) : 0),
 'unit_price_impact' => ($unit ? (float)($unit) : 0),
 'reference' => pSQL($reference),
 'supplier_reference' => pSQL($supplier_reference),
 'location' => pSQL($location),
 'ean13' => pSQL($ean13),
 'upc' => pSQL($upc),
 'default_on' => (int)($default),
 'minimal_quantity' => (int)($minimal_quantity));
 if ($quantity)
  $data['quantity'] = (int)$quantity;
 if (!Db::getInstance()->AutoExecute(_DB_PREFIX_.'product_attribute', $data, 'UPDATE', '`id_product_attribute` = '.(int)($id_product_attribute)) OR !Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'product_attribute_image` WHERE `id_product_attribute` = '.(int)($id_product_attribute)))
  return false;
 if ($quantity)
  Hook::updateProductAttribute($id_product_attribute);
 Product::updateDefaultAttribute($this->id);
 if (empty($id_images))
  return true;
 $query = 'INSERT INTO `'._DB_PREFIX_.'product_attribute_image` (`id_product_attribute`, `id_image`) VALUES ';
 foreach ($id_images AS $id_image)
  $query .= '('.(int)($id_product_attribute).', '.(int)($id_image).'), ';
 $query = trim($query, ', ');
 return Db::getInstance()->Execute($query);
}

 

This is the point where I get a little lost. Do I need to pull some of that code for my script? Do I need to call this function from my script?

 

Any code help here would be much appreciated.

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