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

走远了吗. 提交于 2019-12-08 07:06:35

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/24248395/show-all-spree-ecommerce-products-together-with-their-count-on-hand-displayed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!