Jump to content

Update Product Quantity With External Tool


rubenvincenten

Recommended Posts

So we are going to upgrade to 1.5 soon from 1.3.5.

 

Previously we used an external tool to update the stock for our shop. We did this with a simple query over an ajax request. (Offcourse the code below is stripped of any weird propiarity framework code we internally use)

mysql_connect('localhost','****','****');
mysql_select_db('*****');
$q = (int) $_POST['q'];
$id = (int) $_POST['id'];
if(!$id) die;
mysql_query("update product set quantity = $q where id_product = $id");
die('');

 

Now with the multistore environment, I'm afraid this won't work anymore as I think we need to set the quantity per shop or group.

 

We only have one "warehouse" and we want multiple shops to use the same quantity.

We do not use any product attributes and/or combinations.

 

Please enlighten me how I can do this. My boss doesn't want to use the stock manager that is included within prestashop as we have used an external tool since like forever.

 

Can I just do a simple query like this:

 

mysql_connect('localhost','****','****');
mysql_select_db('*****');
$q = (int) $_POST['q'];
$id = (int) $_POST['id'];
if(!$id) die;
mysql_query("update product set quantity = $q where id_product = $id");
mysql_query("update stock_available set quantity = $q where id_product = $id");
die('');

Or do I need to do additional work?

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

So we are going to upgrade to 1.5 soon from 1.3.5.

 

Previously we used an external tool to update the stock for our shop. We did this with a simple query over an ajax request. (Offcourse the code below is stripped of any weird propiarity framework code we internally use)

mysql_connect('localhost','****','****');
mysql_select_db('*****');
$q = (int) $_POST['q'];
$id = (int) $_POST['id'];
if(!$id) die;
mysql_query("update product set quantity = $q where id_product = $id");
die('');

 

Now with the multistore environment, I'm afraid this won't work anymore as I think we need to set the quantity per shop or group.

 

We only have one "warehouse" and we want multiple shops to use the same quantity.

We do not use any product attributes and/or combinations.

 

Please enlighten me how I can do this. My boss doesn't want to use the stock manager that is included within prestashop as we have used an external tool since like forever.

 

Can I just do a simple query like this:

 

mysql_connect('localhost','****','****');
mysql_select_db('*****');
$q = (int) $_POST['q'];
$id = (int) $_POST['id'];
if(!$id) die;
mysql_query("update product set quantity = $q where id_product = $id");
mysql_query("update stock_available set quantity = $q where id_product = $id");
die('');

Or do I need to do additional work?

 

it isnt great solution, the best way is to use prestashop classes. But if you still want to use this code u have to add additional where instance with ps_shop id for which you want change quantity value of product

 

pr2gy3o.png

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