You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The stock method of the HasStock trait returns the current stock value if no date is given.
It gets the value by summing all the stock mutations the stockable model has.
It works without issues, however if there are thousands of stock mutations and it's required to have a page that shows hundreads of products and their stock, such SQL query might be quite expensive.
I think it would be useful to have an option to save the current stock after a stock mutation, so when calling the stock method without a date, it just returns the value, without the need to sum everything.
Would a PR for this feature be welcome?
The text was updated successfully, but these errors were encountered:
The
stock
method of the HasStock trait returns the current stock value if no date is given.It gets the value by summing all the stock mutations the stockable model has.
It works without issues, however if there are thousands of stock mutations and it's required to have a page that shows hundreads of products and their stock, such SQL query might be quite expensive.
I think it would be useful to have an option to save the current stock after a stock mutation, so when calling the stock method without a date, it just returns the value, without the need to sum everything.
Would a PR for this feature be welcome?
The text was updated successfully, but these errors were encountered: