0

Just found this great article: http://www.blog.magepsycho.com/updating-product-qty-in-magento-in-an-easier-faster-way/ but something works not very well. When I have a CSV with the columns "sku" and "is_in_stock", and I use the script, it also sets the "qty" to 0 when "is_in_stock" is 0. How is that possible? Because I only want to update "is_in_stock", and not the "qty".

Can you help me with this? Thanks in advance!

2 Answers2

1

The linked script ignores the header row and treats the second column as the quantity, regardless that you named it "is_in_stock". That is why "qty" is set to 0.

If all you need is a quick way to mark some items as unstocked:

  1. Go to the admin, then Manage Products.
  2. Search for those you want to change and put a checkmark next to them.
  3. In the Actions box select Update Attributes then click Submit.
  4. On the Inventory tab click the Change box for Stock Availability then select Out of Stock.
  5. Click Save.
clockworkgeek
  • 37,650
  • 9
  • 89
  • 127
  • 1
    Thank you for you answer. That's not possible, because I have a online webshop with 5000 products, that change the stock every hour. My manufacturer gave me an CSV that's not Magento optimized. I made a PHP script that loads the collumns "sku" and "is_in_stock", and cuts all the other rows. The 2 collumns are saved in a seperate CSV. But in the CSV there is no stock-level. Only 0 (= Out of stock) or 1 (Is in stock). The developer gave me this hint: "You need to update the table: cataloginventory_stock_item based on product-id and store-id" –  Sep 30 '12 at 10:23
0

You could use this script instead, http://www.sonassi.com/knowledge-base/magento-kb/mass-update-stock-levels-in-magento-fast/

As a side note, if you have 5000 rows in your CSV, you should retain the previously uploaded file, then perform a diff on the rows that have actually changed - that way, you're only going to be modifying a much smaller number of products.

Ben Lessani
  • 2,141
  • 14
  • 16
  • Thank you for your response! Yes, I am going to use a much bigger CSV, like 6500 products. So that's not an option, but thank you for your answer! –  Oct 02 '12 at 18:08
  • 1
    Why isn't it an option? You only need to update the stock levels **that have changed** - there is little point updating all the product stocks when only a few have changed. – Ben Lessani Oct 02 '12 at 18:10
  • Because I want to update the stocks every hour because my manufacturer exports a new CSV file every hour. But that's 6500 products or so. Already tried that script, but it takes more then 120 seconds (my execution time). The script in my startpost works like a charm, but updates the qty when it's not in stock. –  Oct 02 '12 at 19:02
  • That is fine. But you obviously don't need to update 6500 products **UNLESS** the stock levels have changed for **ALL** 6500 products. You only need to update the stock levels that **have actually changed**. Which is why I said, keep the **previous** stock level file from the last run, then compare the two to check what rows **actually** changed - then just import the resultant file. I highly doubt the stock levels are changing for 6500 products every hour. We run stock sync on stores with 1 million products - and we don't have that kind of sell-through-rate, even on a daily basis. – Ben Lessani Oct 02 '12 at 19:05
  • Okay I now understand what you mean. But, how I should do that? Can I make a script that search for differences in the CSV when comparing to an complete CSV and make an output with the final stocks? –  Oct 02 '12 at 19:12
  • You could do it any number of ways. – Ben Lessani Oct 02 '12 at 19:28
  • Is the Sonassi script still correct and working with later Magento versions? Seems to miss some lines ... – snh_nl Dec 30 '15 at 15:47