en Jump to content
  • 2
marcusnye

Quantity = 0 on CSV import not updating product

Question

I was hoping for some help in my setup. I have a Prestashop install on 1.6.0.14 - I am importing products via CSV from an external stock management system using the normal CSV import routine, which is working really well except for one issue - if a product's stock reduces to 0 (zero) on the CSV import, it is simply ignored on the routine. 

 

ie - 

We have a product with with one item in stock, its sold in our physical shop, the next CSV import shows zero on the file, however Prestashop continues to show 1 in stock.

Any figure above 0 updates perfectly, so if i change it on the CSV to quantity of 5, it updates. If i then change it back to 0, Prestashop remains at 5

 

Is this by design or is there a workaround?

 

For now, its a case or manually updating the stock on Prestashop down to zero when something is sold outside of the shop, but we are bound to miss something!

 

Many thanks in advance!

 

The file contains:

Reference#,Name,PriceTaxExcluded,Quantity,WholesalePrice

 

post-1011459-0-18358800-1432027630_thumb.jpg

 

Share this post


Link to post
Share on other sites

42 answers to this question

Recommended Posts

  • 0

UPDATE: I updated my Patch for Presta version 1.6.1.17

Just copy the file to /override/controllers/admin/ 

Download: AdminImportController.php

Old Patch file (do not use):  AdminImportController.diff.txt

On 12.6.2015 at 12:59 PM, shacker said:

sorry, product reference,  And select the option to force product refrence as keyword

 

Ok. I tried as you reccommend, but my quantities do not change to "0".

I'm not sure if this is caused by the multistore configuration or because we do not use the advanced stock management.

 

I was able to find the reason why this is not working in our setup.

in controllers/admin/AdminImportController.php Line 1827 the product quantity is checked. If quantity is 0 no database update will be done.

I suppose this should prevent overwriting all stock values with zero if a empty quantities column is imported, but it also prevents setting a stock value to zero via csv-import.

 

I changed this and a second check and now my import will write zero values just fine.

 

Diff file attached.

 

 

 

 

Edited by juergen-sfx
Updated Solution

Share this post


Link to post
Share on other sites
  • 0

try to import only product rec and quantity, this overrides all values

 

Please elaborate what you mean with "product rec"

 

I tried to import a test CSV with this data:

ID;Quantity
4868;0

This will not update the products quantity value.

 

We are using Presta version 1.6.0.14

Share this post


Link to post
Share on other sites
  • 0

sorry, if you quantity in the CSV its zero, the system dont update. That have sense because maybe you have stock in your store, but your supplier not. You can change in the CSV the zer ovalues of stock to -1, that did the trick

Share this post


Link to post
Share on other sites
  • 0

thanks for your help so far, looked promising, but when I made the changes from the diff file juergen-sfx offered, but i tried a couple of times and each time it broke the CSV import option (blank white screen).

 

So i tried the suggestion of -1 for stock but it ignores this too.

 

Its a weird one this, we only have one parts warehouse, and when the quantity is zero, we can't sell any more until stock is obtained from distribution. So wouldn't want to sell something that's physically not on premises

Share this post


Link to post
Share on other sites
  • 0

attachicon.gifAdminImportController.diff.txt

 

Ok. I tried as you reccommend, but my quantities do not change to "0".

I'm not sure if this is caused by the multistore configuration or because we do not use the advanced stock management.

 

I was able to find the reason why this is not working in our setup.

in controllers/admin/AdminImportController.php Line 1827 the product quantity is checked. If quantity is 0 no database update will be done.

I suppose this should prevent overwriting all stock values with zero if a empty quantities column is imported, but it also prevents setting a stock value to zero via csv-import.

 

I changed this and a second check and now my import will write zero values just fine.

 

Diff file attached.

 

 

Thanks!!! Its really solve the problem!

I have PS 1.6.0.14

Share this post


Link to post
Share on other sites
  • 0

i think works as usual, becouse 0 stock means that the privider dont have stock, but you have stock in your store

0 stock is 0 stock.

 

I think this is a bug in this version (I'm using 1.6.0.13) because it worked properly before.

 

I'm sure it's an issue of the latest versions of Prestashop because this also happens in the "Discount percent" column of the CSV. When I want to delete a discount and change to 0, no catches it, it only works if I put a minimum of 1, and that does not make any sense. That's why I wonder if in the latest version of Prestashop this is solved.

Edited by lixotuka

Share this post


Link to post
Share on other sites
  • 0

attachicon.gifAdminImportController.diff.txt

 

Ok. I tried as you reccommend, but my quantities do not change to "0".

I'm not sure if this is caused by the multistore configuration or because we do not use the advanced stock management.

 

I was able to find the reason why this is not working in our setup.

in controllers/admin/AdminImportController.php Line 1827 the product quantity is checked. If quantity is 0 no database update will be done.

I suppose this should prevent overwriting all stock values with zero if a empty quantities column is imported, but it also prevents setting a stock value to zero via csv-import.

 

I changed this and a second check and now my import will write zero values just fine.

 

Diff file attached.

 

Hey Magic!

 

I lookin for answer to try repair my quantity upload 0 via CSV

I found your post, some people says its works but my ~ line 1827 and near this in AdminImportController.php is dont have any code about quantity.

 

I attached my code from this file - can You look at this and please give some suggestions/instructions or smth?

 

Its Prestashop 1.6.1.2

 

This is my last needed modification in presta, and i spend like 4 days about that issue, no effect :-(

 

Ah, i just try to found your start and ending sections of code what u give me and change it, doesn't work - error page when trying load import csv page :/

AdminImportController.php.txt

Edited by zgredek

Share this post


Link to post
Share on other sites
  • 0

thanks this worked for me -1 works  thanks @PrestaShop Legend

 

in combination file i changed stock to "-1" and in back office it shows "-1 stock" and in front office the product page buy button is gone"

 

so it worked for me

Edited by snehalmcse

Share this post


Link to post
Share on other sites
  • 0

Hi,

 

I have a similar problem: in the last month, when a product is sold I receive a notification on the backoffice "recent orders", but when I go to the order, it doesn´t say which product was sold, only the cost of the sold product and the product is still available (in my shop I only have 1 product of each, so when it ´s sold it should get out of stock and show 0 in the backoffice, but it doesn´t... Luckily I have different prices in almos all products, so I could discover the one which has been sold. 

 

Can anyone please help me?

Share this post


Link to post
Share on other sites
  • 0

Hi - I'm really new to this. I want to update my products stock from the supplier every day ideally. I have uploaded the products with a csv file including quantities. When I now try and upload a csv file to update the quantites it doesn't change them even though it says the upload was successful.

 

I have looked in cpanel public html, controller, then adminimport controller and can't see the line you say to change either 1929 or 1827. Can anyone help? Am I doing the right thing in cpanel?

There is a lot about quantities in 1929 but am really struggling and don't want to make a massive mistake.

 

I also don't want to use advanced stock management but just a csv upload to change the quantity. I don't really want to spend over £100 on some mass management module if possible. Can anyone help?

Edited by susieb

Share this post


Link to post
Share on other sites
  • 0

attachicon.gifAdminImportController.diff.txt

 

Ok. I tried as you reccommend, but my quantities do not change to "0".

I'm not sure if this is caused by the multistore configuration or because we do not use the advanced stock management.

 

I was able to find the reason why this is not working in our setup.

in controllers/admin/AdminImportController.php Line 1827 the product quantity is checked. If quantity is 0 no database update will be done.

I suppose this should prevent overwriting all stock values with zero if a empty quantities column is imported, but it also prevents setting a stock value to zero via csv-import.

 

I changed this and a second check and now my import will write zero values just fine.

 

Diff file attached.

i couldn't manage to open diff file. i'm noob at developing. Is it possible to send your edited file or explain how to do with different something?

Share this post


Link to post
Share on other sites
  • 0

i couldn't manage to open diff file. i'm noob at developing. Is it possible to send your edited file or explain how to do with different something?

Hi. I cannot send you the file, because this thread is pretty old and I did not update my patch to recent versions of PrestaShop.

Open the File in a decent text Editor like Notepad++, Sublime, Textmate or Gedit. 

Search in your file for the lines marked with a leading "-" and replace them with the ones marked with a leading "+". Do not add the "+" Character to your File!

Share this post


Link to post
Share on other sites
  • 0

Hi , i have the same problem .  i have try to delete this : && (int)$product->quantity    at line 1929   (PS1614)

 

But dont work for me , i have error : activate stock advanced , i have do it .. but always error

Share this post


Link to post
Share on other sites
  • 0

Hello, im in trouble here! 

 

i also have a problem updating my quantities through CSV importing, my product updates quantity to "8", as i can see on catalog search, but in product details, my product still remains with quantity "1". (presta 1.6.0.8)

 

In the database i found the new value stored in ps_stock_available -> quantity but not in ps_product-quantity... So manually all is updated fine, but with importing tool, only the quantity in ps_stock_available is updated.

 

How can i solve this?

 

Thanks for the help.

Share this post


Link to post
Share on other sites
  • 0

Hello,

 

I'm using version 1.6.1.6 and also have this problem, if quantity "0" , update not worked

 

How can i solve this?

 

Thanks for the help.

Share this post


Link to post
Share on other sites
  • 0

Hello,

 

I'm using version 1.6.1.6 and also have this problem, if quantity "0" , update not worked

 

How can i solve this?

 

Thanks for the help.

check this post. the solution is change the adminimportcontroller.php

Share this post


Link to post
Share on other sites
  • 0

hi,

I have the same problem, I use PS 1.6.1.4

 

if I write -1 works, if I write 0 (zero) doesn't works

 

any suggestion?

Thanks

Share this post


Link to post
Share on other sites
  • 0

you delete the class_index.php in cache folder?

 

Thanks, when I has deleted this file, Import with "0" is worked.

Share this post


Link to post
Share on other sites
  • 0

hi,

I have the same problem, I use PS 1.6.1.4

 

if I write -1 works, if I write 0 (zero) doesn't works

 

any suggestion?

Thanks

 

Try to search and remove && (int)$product->quantity, in controllers/admin/AdminImportController.php.

 

After this, you need delete the class_index.php in cache folder, Prestashop make new

Share this post


Link to post
Share on other sites
  • 0

Try to search and remove && (int)$product->quantity, in controllers/admin/AdminImportController.php.

 

After this, you need delete the class_index.php in cache folder, Prestashop make new

thanks, I'll try and I'll come back soon

Share this post


Link to post
Share on other sites
  • 0
tyz    0

eliminar && int $ product -> quantity , en controllers / admin / AdminImportController.php

funciona ok    PS 1.6.1.1

Share this post


Link to post
Share on other sites
  • 0

need help, my csv import is not working now after overwriting with the new adminimportcontroller, i downloaded orginal file from prestashop and overwrite but still not able to see csv import page when clicked on !!!

Share this post


Link to post
Share on other sites
  • 0

 

It is not recommended to modify the controllers directly. Instead, a copy of the AdminImportController file found in "controllers / admin" should be made to the "override" folder. The file that we will modify is the one that we just copied. Then, for the changes to take effect we must delete the file "class_index.php" from the folder "cache" so that Prestashop can regenerate it

A greeting.

 

Arminet

Edited by Arminet

Share this post


Link to post
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

×

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More