Wolfish
Wolfish

Reputation: 13

Show all spree ecommerce products together with their count-on-hand displayed

How can I show all products and their counts together in one place in Spree Commerce? The only place I see the count_on_hand implemented is in admin/stock_transfers and even then it's several clicks deep for the administrator.

 admin --> configuration --> stock transfers --> view transfer

and then you can see a count on hand variable displayed per item.

enter image description here

Upvotes: 1

Views: 809

Answers (1)

gmacdougall
gmacdougall

Reputation: 4901

Each product has a total on hand method defined here:

https://github.com/spree/spree/blob/v2.2.2/core/app/models/spree/product.rb#L200-L206

You can iterate through all products, and call total_on_hand to find the number of those products on hand (for all variants and stock locations).

Upvotes: 1

Related Questions