rseigel Posted September 20, 2012 Share Posted September 20, 2012 Sorry for the double post but I thought this topic might more action here. 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 More sharing options...
rseigel Posted September 20, 2012 Author Share Posted September 20, 2012 Anyone? Link to comment Share on other sites More sharing options...
CrS27 Posted September 21, 2012 Share Posted September 21, 2012 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 More sharing options...
math_php Posted September 21, 2012 Share Posted September 21, 2012 Hi Rseigel I am not sure but as your code is stand alone it will not trigger 'automatic ' actions in Prestashop. Perphaps $product->update() (for each product) may trigger the behaviour you are looking for i will try to find this. 1 Link to comment Share on other sites More sharing options...
math_php Posted September 21, 2012 Share Posted September 21, 2012 It seems that "back in stock" is present in paid module. Wich one do you use ? Developper of your module could also answer you. 1 Link to comment Share on other sites More sharing options...
rseigel Posted September 21, 2012 Author Share Posted September 21, 2012 I don't use a module. It's just stand alone code I wrote. Do you have the snippet that will accomplish what I'm looking for? Link to comment Share on other sites More sharing options...
rseigel Posted September 21, 2012 Author Share Posted September 21, 2012 (edited) 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. Edited September 21, 2012 by rseigel (see edit history) Link to comment Share on other sites More sharing options...
math_php Posted September 22, 2012 Share Posted September 22, 2012 Hi, Ok now I figured what module was in use The back in stock is triggered by several hooks, the most interesting hook seems to be the 'updateQuantity' one. In product class you will find updateQuantity($product, $id_order = NULL) that could fit Cheers Link to comment Share on other sites More sharing options...
rseigel Posted September 22, 2012 Author Share Posted September 22, 2012 Hmmmm.....I'll have to look at it closer and see if I can make anything of it. Thanks. Link to comment Share on other sites More sharing options...
rseigel Posted September 22, 2012 Author Share Posted September 22, 2012 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 More sharing options...
rseigel Posted September 28, 2012 Author Share Posted September 28, 2012 I finally upgraded to 1.5 and I'm still hoping someone can help with this issue. Link to comment Share on other sites More sharing options...
CartExpert.net Posted September 28, 2012 Share Posted September 28, 2012 Hi. The best solution would be to modify the mail alerts and hook it to updateproduct maybe. Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now