Jump to content

Change products Qty in PhpmyAdmin - MultiStore


Recommended Posts

Hello guys,

 

i have multi-store activated, i have 3 stores.

 

- when i change Qty in ps_products table, Qty doesn't change in prestashop backend.

- when i change Qty in backend, Qty in ps_products table doesn't change, in fact, i get a new row in ps_stock_available table with the product that i change Qty for.

- can someone tell me exactly what to do to change all product's Qty in 3 stores to "1" ?

 

Thank you

Link to comment
Share on other sites

This is not exact what you need but when you have basic knowledge you can put that in a self coded module and modify it to your needs.

$products = Db::getInstance()->ExecuteS('SELECT id_product, quantity FROM `ps_product` WHERE advanced_stock_management=0' );

   foreach ($products AS $product)
   {
   Db::getInstance()->Execute('INSERT INTO `ps_stock_available`(`id_product`, `id_product_attribute`, `id_shop`, `id_shop_group`, `quantity`, `depends_on_stock`, `out_of_stock`) VALUES ('.$product['id_product'].',0,0,1,'.$product['quantity'].',0,0)');
  }

The imo cleaner function is

StockAvailable::setQuantity(Tools::getValue('id_product'), '', Tools::getValue('quantity'));

. So but please modify it to your needs and test this on a test installation.

Link to comment
Share on other sites

There is no easy query. As you found out not all product id's are stored in the stock available from the beginning. Imo it is easier to generate the queries in php but I've seen you can make loops in MySQL too.

http://dev.mysql.com/doc/refman/5.0/en/loop.htm

The basic principle in my approach is loop through all products in ps_product and copy the id's and amount to product_available. I doubt that anybody here built a mysql query doing that.

Good luck with that, trip

Link to comment
Share on other sites

  • 1 year later...

Can any one suggest me on how to update product attributes from phpmyadmin.

 

Like : for Product A which is in ps_product table with reference and id_product whose combination/attribute is in ps_stock_available

 

For example : I have to update all the attributes for a product. I am unable to map id_product_attribute.

 

Product A has 4 attributes :

  1. A1
  2. A2
  3. A3
  4. A4

And for each I have to update Quantity so what will be the UPDATE Query assuming that we have ONLY reference and quantity.

 

Please Guide.

Link to comment
Share on other sites

×
×
  • Create New...