Jump to content

[SOLVED] Automatic price update for Products and combinations


chapster

Recommended Posts

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

  • 1 month later...

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();
  1. 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.
  2. The quantity is not  changing at all. 
  3. 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 by topall (see edit history)
Link to comment
Share on other sites

	/**
	 * 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

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