How to get the Total stock quantity of the products track by product attribute

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 года назад
In the Administration >> catalog>> product, we have a list of all the products added in the store. in this list, for the products with "the inventory track by product attribute," the stock quantity is not displayed. how could I get the total Stock quantity of the product set as a track by attribute?
3 года назад
I also trying to do the same. If anyone know how can I get the total product stock when the stock is controlled by attributes.

Thanks
3 года назад
You would need to customize/override PrepareProductListModelAsync in the ProductModelFactory:
https://github.com/nopSolutions/nopCommerce/blob/ecb1bb8eed4d07018d268060a7cbfaea880b2140/src/Presentation/Nop.Web/Areas/Admin/Factories/ProductModelFactory.cs#L757

And GetTotalStockQuantityAsync in the ProductService:
https://github.com/nopSolutions/nopCommerce/blob/ecb1bb8eed4d07018d268060a7cbfaea880b2140/src/Libraries/Nop.Services/Catalog/ProductService.cs#L1365

You could sum the product's attribute stock quantities, or use something like an EventConsumer to update/sum a product's overall stock quantity as its attributes sell.  You'll need to account for stock quantity history too, if you utilize that feature.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.