如何在 Spree Commerce 的一个地方同时显示所有产品及其数量?我看到 count_on_hand 实现的唯一地方是在 admin/stock_transfers 中,即使这样,管理员也需要多次点击。
admin --> configuration --> stock transfers --> view transfer
然后你可以看到每个项目显示的手头变量。
如何在 Spree Commerce 的一个地方同时显示所有产品及其数量?我看到 count_on_hand 实现的唯一地方是在 admin/stock_transfers 中,即使这样,管理员也需要多次点击。
admin --> configuration --> stock transfers --> view transfer
然后你可以看到每个项目显示的手头变量。
每个产品都有一个在这里定义的总手头方法:
https://github.com/spree/spree/blob/v2.2.2/core/app/models/spree/product.rb#L200-L206
您可以遍历所有产品,并调用 total_on_hand 以查找现有产品的数量(针对所有变体和库存位置)。