Claudiu Nesa Posted November 21, 2012 Share Posted November 21, 2012 Hi, Does anyone know how to update a certain product price from a custom module. I try to make something like this: after 10 days I want to update the price of the product with +/-2% depending on some variables that I'm creating inside my module. I searched all over the internet and also in prestashop classes in order to find a method that simply updates the price of a product but with no luck so far. I even thought to update it manually by executing an insert directly from my module but I noticed that it won't be a good approach. Thank you in advance, C. Link to comment Share on other sites More sharing options...
Claudiu Nesa Posted November 22, 2012 Author Share Posted November 22, 2012 Isn't there nobody to help me with this issue !?! Link to comment Share on other sites More sharing options...
math_php Posted November 23, 2012 Share Posted November 23, 2012 Hi Claudiu, With the new_price and the id_product of the product you want to udpate : $product = new Product($id_product); $product->price = $new_price; $product->update(); You will perhaps have to deal with wholesale_price. Regards 2 Link to comment Share on other sites More sharing options...
Claudiu Nesa Posted November 23, 2012 Author Share Posted November 23, 2012 Hi Claudiu, With the new_price and the id_product of the product you want to udpate : $product = new Product($id_product); $product->price = $new_price; $product->update(); You will perhaps have to deal with wholesale_price. Regards Thank you. Much appreciate. Link to comment Share on other sites More sharing options...
Claudiu Nesa Posted November 27, 2012 Author Share Posted November 27, 2012 Hi Claudiu, With the new_price and the id_product of the product you want to udpate : $product = new Product($id_product); $product->price = $new_price; $product->update(); You will perhaps have to deal with wholesale_price. Regards Is there something else that I should do after $product->update(); 'cause it does not change the price in the database for that product. Thank you! Link to comment Share on other sites More sharing options...
math_php Posted November 27, 2012 Share Posted November 27, 2012 Hi Claudiu, Do you have specific prices ? If you make a test on one product (id_product 22) and look in mysql the price is still the same ? Try also this code. $product = new Product((int)$id_product); $product->price = (float)$new_price; $product->update(); Tell me if it does not work. Regards Link to comment Share on other sites More sharing options...
ondapc Posted April 3, 2013 Share Posted April 3, 2013 (edited) Now if someone could explain how to update an entire mysql query I would be very happy Edited April 4, 2013 by ondapc (see edit history) Link to comment Share on other sites More sharing options...
math_php Posted April 4, 2013 Share Posted April 4, 2013 Hi ondapc Before asking for explanation you can : - write 'Hello' because even computer have 'handshake' or 'session start'.... - check the way you make weird foreach php loop - choose words : 'mysql' has nothing to do here it is hidden - thanks in advance for free support 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