Jump to content

[solved] Fatal error (StockMvt -> id_stock_mvt_reason = -1)


Recommended Posts

Getting this error when I alter a product: Fatal error (StockMvt -> id_stock_mvt_reason = -1) (see attached image)

Searched the forum and have found this solution:

Open table "ps_stock_mvt_reason"
remove auto increment on id_stock_mvt_reason,
and create a record:
id_stock_mvt_reason = 0
sign = 1

I've applied this and still get the above error.

Any help would be greatly appreciated.
Thanks,
Rob

40621_AWjxtt3P0H0Z6Q08UGcz_t

Link to comment
Share on other sites

Hi,

This is in the Bug Report... but a few people have managed to fix it by setting the default stock movement reason from "order" to "increase". To do so, go to the BO, click Catalog --> Stock Movement, then scroll down to the bottom.

HTH!

PS. Post a follow up if this works for you... ithink there are a few bugs with this new stock movement feature. I don't even know what is its purpose.

Link to comment
Share on other sites

Hi,

...a few people have managed to fix it by setting the default stock movement reason from "order" to "increase". To do so, go to the BO, click Catalog --> Stock Movement, then scroll down to the bottom.


Actually, I didn't have a default setting for Stock Movement Reason. (See attached) instead there is ID 0 with the name " - "

I wonder if this is the same for everyone? I upgraded to version 1.4 - not from a clean install.

I will post back when I think it is solved.

40642_hltMpmmNPBYJGeeNq5Gr_t

Link to comment
Share on other sites

Raggy786,
Have you applied the database fix from my first message? I know that when I turned off auto increment kept increasing in ps_stock_mvt_reason. Then I turned auto increment on and then off and for some reason it seems to be working.

I haven't needed to change any setting in Catalog —> Stock Movement as suggested by mytheory above.

HTH

Link to comment
Share on other sites

I dont understand your sql query


No problem. Do you have access to PHPMYADMIN? Assuming you do, navigate to your database and find the following table:

YOURPREFIX_stock_mvt_reason


Follow the images:
1. Table in MySQL
2. Click on Structure
3. edit id_stock_mvt_reason
4. turn off auto_increment
5. save changes

No Images for the following
6. Next to Structure click on BROWSE
7. There should only be one row of information (Let me know if there is more as I'm not too sure how this table actually works)
8. Click the edit pencil
9. Where it says "id_stock_mvt_reason" set "VALUE" to 0 (zero)
10 Where it says "sign" set "VALUE" to 1 (one)

Save by clicking GO.

Hope it works. Cheers,
Rob

40701_ROsbVZH1NAxaePQQIuhs_t

40700_IvOlwog70DiU9rsaU2eq_t

40699_CGkRE8xXEDIi1hcLWhFL_t

40702_b14dn6e0opZu8TDxBvOz_t

  • Like 1
Link to comment
Share on other sites

that was great. But i do not have one row. I have 5 Rows. lol that is why its confusing.

7. There should only be one row of information (Let me know if there is more as I’m not too sure how this table actually works)

( more than one row )

Link to comment
Share on other sites

Ok. Looks like maybe we just need to understand how the Stock Movements actually works eh? I don't need it as our on-line presence is quite personable. We contact each customer and handle all stock through MYOB.

My guess is to delete those extra rows in id_stock_mvt_reason and leave just the one as suggested above. Obviously back up your DB in case it causes problems - but I think you're pretty safe.

Cheers

Link to comment
Share on other sites

@ Koolrifz / Rob - Thank you so much for your 'hack' ;)

Indeed the default was set to autoincrement. There were also other rows, as the default data comes along with options to increase, decrease, order, 'misplaced' ?? I guess with time, maybe this will be useful when we know how to use it ;)

I noticed the following when searching for a resolve. This may well be a bug. http://www.prestashop.com/bug_tracker/view/8372/

Thanks again

Ally

Link to comment
Share on other sites

Hi,

This is in the Bug Report... but a few people have managed to fix it by setting the default stock movement reason from "order" to "increase". To do so, go to the BO, click Catalog --> Stock Movement, then scroll down to the bottom.

HTH!

PS. Post a follow up if this works for you... ithink there are a few bugs with this new stock movement feature. I don't even know what is its purpose.


This worked for me!

Cheers for the suggestion
Link to comment
Share on other sites

Getting this error when I alter a product: Fatal error (StockMvt -> id_stock_mvt_reason = -1) (see attached image)

Searched the forum and have found this solution:

Open table "ps_stock_mvt_reason"
remove auto increment on id_stock_mvt_reason,
and create a record:
id_stock_mvt_reason = 0
sign = 1

I've applied this and still get the above error.

Any help would be greatly appreciated.
Thanks,
Rob


Thank you for the hack, it solved my problem
Link to comment
Share on other sites

9-10 screenshot

Bu ti get

SQL query: Edit

UPDATE `mobila_badie`.`ps_stock_mvt_reason` SET `id_stock_mvt_reason` = '0',
`sign` = '1' WHERE `ps_stock_mvt_reason`.`id_stock_mvt_reason` =4

MySQL said: Documentation
#1062 - Duplicate entry '0' for key 1 



EDIT : It works if i get only sign = 1 for all

LATER EDIT : I still get the same error Fatal error (StockMvt -> id_stock_mvt_reason = -1)

41694_dwuUVnCA9Qas1cerVgTF_t

41695_NQoWnP0NCObSYQaFVdYn_t

Link to comment
Share on other sites

@vietnam

sorry but I don't understand your problem. The only thing what you have to do is to set the in your DB the table ps_stock_mvt_reason to: NULL instead of auto increment and than reasign again auto increment. For me the error disappeared and I'm able to manage stock without any problems and any error-message on products...

Link to comment
Share on other sites

@vietnam

sorry but I don't understand your problem. The only thing what you have to do is to set the in your DB the table ps_stock_mvt_reason to: NULL instead of auto increment and than reasign again auto increment. For me the error disappeared and I'm able to manage stock without any problems and any error-message on products...


I do not understand exatly how

SQL query:

ALTER TABLE `ps_stock_mvt_reason` CHANGE `id_stock_mvt_reason` `id_stock_mvt_reason` INT( 11 ) NOT NULL DEFAULT NULL

MySQL said: Documentation
#1067 - Invalid default value for 'id_stock_mvt_reason' 



Then i tried

ALTER TABLE `ps_stock_mvt_reason` CHANGE `id_stock_mvt_reason` `id_stock_mvt_reason` INT( 11 ) NULL 



ALTER TABLE `ps_stock_mvt_reason` CHANGE `id_stock_mvt_reason` `id_stock_mvt_reason` INT( 11 ) NOT NULL AUTO_INCREMENT 

Link to comment
Share on other sites

i recently upgraded 2 presta shops from v1.2 to v1.4 and the only thing i did was to change the stock order to increase, saved, then changed back to order and saved.

I did not experience any problems on these sites, but I did the above because of a new 1.4 installation i previously performed had the issues described here. Simply doing the above solved the problem for me without having to modify any records/tables in mysql directly.

Link to comment
Share on other sites

i recently upgraded 2 presta shops from v1.2 to v1.4 and the only thing i did was to change the stock order to increase, saved, then changed back to order and saved.

I did not experience any problems on these sites, but I did the above because of a new 1.4 installation i previously performed had the issues described here. Simply doing the above solved the problem for me without having to modify any records/tables in mysql directly.


I have used the same solution as http://www.prestashop.com/forums/viewreply/402830/ and as yours lellini13 and yes, this one worked
Link to comment
Share on other sites

Hi guys,

Had the same problem after an update from 1.2.5.0 to 1.4.0.17. I tried first changing the default stock movement reason to something (actually it doesn't matter to what). It stopped the error, but every time I modified something in the product page it added another row in ps_stock_mvt table. Very annoying! It should check if the movement stock quantity is zero and if it is, it should do nothing!

So I looked for the function - it is addStockMvt from /classes/product.php. So I made an override adding at its start

if ($quantity == 0)
 return true;



I also attached a file that can be put in /override/classes. I removed my other overrides so I didn't try it in this form, but it should work ok.

All in all, I had to fight a fair share of bugs in this upgrade. I'm somehow dissappointed in Presta's Quality Control department. Oh well...

All the best.

Product.php

Link to comment
Share on other sites

Hi,

This is in the Bug Report... but a few people have managed to fix it by setting the default stock movement reason from "order" to "increase". To do so, go to the BO, click Catalog --> Stock Movement, then scroll down to the bottom.

HTH!

PS. Post a follow up if this works for you... ithink there are a few bugs with this new stock movement feature. I don't even know what is its purpose.


worked for me. many thanks
Link to comment
Share on other sites

  • 3 weeks later...
  • 5 months later...

 

No problem. Do you have access to PHPMYADMIN? Assuming you do, navigate to your database and find the following table:

YOURPREFIX_stock_mvt_reason

Follow the images:

1. Table in MySQL

2. Click on Structure

3. edit id_stock_mvt_reason

4. turn off auto_increment

5. save changes

No Images for the following

6. Next to Structure click on BROWSE

7. There should only be one row of information (Let me know if there is more as I'm not too sure how this table actually works)

8. Click the edit pencil

9. Where it says "id_stock_mvt_reason" set "VALUE" to 0 (zero)

10 Where it says "sign" set "VALUE" to 1 (one)

Save by clicking GO.

Hope it works. Cheers,

Rob

Hi, I have same problem... I am a novice in these matters. What do u mean "PHPADMIN" access. I have admin acces in prestashop of site and ftp acces, so what more i need to do so i can fix this problem. And what i need to do programs or something step by step. Thank you for patience.

Link to comment
Share on other sites

  • 4 months later...

Hi Guys,

 

i also faced the same issue in updating the prestashop 1.3 to 1.4.

Did lot of RND but didn't got the solutons.

 

At last after spending lot of time i found one permanent solutions to the problem.

 

First of all, the problem rises because there is no option called "Stock Movements" in Prestashop 1.3 and this is the new feature added to the Prestashop 1.4. So the when we add new product it checks for the value of "id_mvt_reason" in the Product class which returns -1 which in-return creates problem in adding new product.

 

Solution: We don't have to make any modification anywhere in the Database; what we need to do is just go to "Tools.php" file inside classes folder and look for the getValue$key, $defaultValue = false) function in that. It would be on line no. 208 i guess not sure it depends upon the changes in the file.

 

Just replace the following code in that function:

 

return !is_string($ret)? $ret : stripslashes($ret);

 

with

 

 

if($key != 'id_mvt_reason')

return !is_string($ret)? $ret : stripslashes($ret);

else

return 1;

 

And just upload the file and check.

 

Your problem goes away forever.

 

Please Note: I'm not aware of the "Stock Movement" functionality; and those who knows please check that doesn't break their code.

 

Cheers Guys!!!

 

Varinder Singh

Link to comment
Share on other sites

Hi Guys,

 

i also faced the same issue in updating the prestashop 1.3 to 1.4.

Did lot of RND but didn't got the solutons.

 

At last after spending lot of time i found one permanent solutions to the problem.

 

First of all, the problem rises because there is no option called "Stock Movements" in Prestashop 1.3 and this is the new feature added to the Prestashop 1.4. So the when we add new product it checks for the value of "id_mvt_reason" in the Product class which returns -1 which in-return creates problem in adding new product.

 

Solution: We don't have to make any modification anywhere in the Database; what we need to do is just go to "Tools.php" file inside classes folder and look for the getValue$key, $defaultValue = false) function in that. It would be on line no. 208 i guess not sure it depends upon the changes in the file.

 

Just replace the following code in that function:

 

return !is_string($ret)? $ret : stripslashes($ret);

 

with

 

 

if($key != 'id_mvt_reason')

return !is_string($ret)? $ret : stripslashes($ret);

else

return 1;

 

And just upload the file and check.

 

Your problem goes away forever.

 

Please Note: I'm not aware of the "Stock Movement" functionality; and those who knows please check that doesn't break their code.

 

Cheers Guys!!!

 

Varinder Singh

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