chapster Posted October 31, 2013 Share Posted October 31, 2013 Hi, I have to create script, which updates quantities and prices. For quantities I found this static method StockAvailable::setQuantity($product,$attribute, $value). Is there similar funcion for setting prices? I didn't found any function and with SQL update prices I have some cache problems. Thanks. Chap Link to comment Share on other sites More sharing options...
vekia Posted November 1, 2013 Share Posted November 1, 2013 $product = new Product(6); $product->price=20; $product->update(); Link to comment Share on other sites More sharing options...
chapster Posted November 1, 2013 Author Share Posted November 1, 2013 Thanks. And what about setting price difference of product attributes? For me would be best to set final price of every combination. Otherwise at least set that difference to product price. Chap Link to comment Share on other sites More sharing options...
vekia Posted November 1, 2013 Share Posted November 1, 2013 it will be very similar: $combination = new combination (200); $combination->price=19.99; $combination->update(); 1 Link to comment Share on other sites More sharing options...
chapster Posted November 2, 2013 Author Share Posted November 2, 2013 Nice! Thank you very much. Problem solved. Link to comment Share on other sites More sharing options...
vekia Posted November 2, 2013 Share Posted November 2, 2013 you're welcome glad to hear that i could help you a little in this case topic marked as [solved] with regards, Milos Link to comment Share on other sites More sharing options...
topall Posted December 8, 2013 Share Posted December 8, 2013 $product = new Product(6); $product->price=20; $product->update(); I'm using multistore. when I try to do like this the price of the product not changing and but some other fields are. why? Link to comment Share on other sites More sharing options...
vekia Posted December 9, 2013 Share Posted December 9, 2013 maybe you've got combinations? Link to comment Share on other sites More sharing options...
topall Posted December 9, 2013 Share Posted December 9, 2013 (edited) maybe you've got combinations? Look. I have 1 combination only for my product. I have that product available for one store only in my multistore. Then When I'm using $product->price=20; $product->quantity=33; $product->update(); The price is changing in DB only. In BO I see the same prices. But I want to change the price which displays in BO product list under Final price column. How can I do that? I didn't find any specific methods to do that. The quantity is not changing at all. update() method switch a lot of fields in DB to 0. Everything is okey If I use Product->update(true, false). Is it normal behavior for update method? Edited December 9, 2013 by topall (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted December 9, 2013 Share Posted December 9, 2013 /** * Update current object to database * * @param bool $null_values * @return boolean Update result */ public function update($null_values = false) { you use two params in this function? sounds really weird that it works Link to comment Share on other sites More sharing options...
topall Posted December 9, 2013 Share Posted December 9, 2013 /** * Update current object to database * * @param bool $null_values * @return boolean Update result */ public function update($null_values = false) { you use two params in this function? sounds really weird that it works The weird thing is the behavior of updating products for multistore in Prestashop. Finally I've solved my problem with that. So, i have 2 shop groups and 1 shop in each group. The first one is default shop and I want to update a product which exists in the 2nd shop only. But when i try to do so $product = new Product(6, true, null, $id_shop); $product->price=20; $product->update(); Prestashop creates a new product in the first(default) shop. It's really weird. In the end I solved it like this Shop::setContext(Shop::CONTEXT_SHOP, $id_shop); But I guess it's a bug. Or give me the better clue. 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