0

We need to update the stock levels of lots of products following off-site sales. Rather than click though to the details of every product, is there a way of quickly updating the stock figure from a table view without having to leave the table?

Or is the best way to export/import and amend via a spreadsheet?

I'd be grateful for any pointers.

Thanks

2

3 Answers 3

2

it is not good practices to update inventory direct from database table. You can import it using CSV or programmatically using below code :

$stockItem = $this->stockRegistry->getStockItem($entity_id);
$stockItem->setData('qty', $qty);
$stockItem->setData('is_in_stock', ($qty > 0 ) ? 1 : 0); 
$stockItem->save(); 

Thanks

1

Best and easy way is to update product stock is

Go to admin side -> Catalog -> Products -> Select products from the grid which you want to update stock

After that click on Action dropdown -> select Update Attrbites

enter image description here

after that go to Advanced Inventory tab and manage your stock like quantity etc

3
  • Thanks Hitesh - I can see this is useful for applying the same stock level to many products, but I need to update each individually and am trying to avoid having to click through to the product details of every product.
    – Andrew
    Nov 30, 2018 at 12:05
  • Ok go it, then you can do first export your all products do your changes of quantity and others, and re-import it all
    – Hitesh
    Nov 30, 2018 at 12:08
  • you can follow this link alexcorradi.org/blog/…
    – Hitesh
    Nov 30, 2018 at 12:09
1

It's not best practice, but you can also use a direct SQL method which would be much quicker - though as it wouldn't trigger a product save, it wouldn't destroy the cache for those products so you would need to flush cache.

Here's the sql to show you the sku, stock position and whether its marked as in stock;

SELECT p.sku, i.qty, i.is_in_stock 
FROM dbname.cataloginventory_stock_item i, dbname.catalog_product_entity p 
WHERE p.entity_id = i.product_id 
AND i.stock_id = 1

Obviously ensure that if the stock position is greater than 0, make sure is_in_stock is set to 1, otherwise set it to 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.