What is the difference between isSaleable() and isAvailable()?

后端 未结 5 1716
无人共我
无人共我 2021-01-30 19:46

I\'m working on the display of the stock availability on the (individual) product page of my Magento theme, and there\'s something I don\'t completely understand about this.

5条回答
  •  [愿得一人]
    2021-01-30 20:32

    If I'm not mistaken, the difference in these checks has to do with reservations of products for placed orders. When a customer adds products to an order, these products will still be in your stock, so they are still available. Though, they aren't saleable, because they have already been ordered by another customer.

    So the semantic difference is:

    • saleable means: in stock and not ordered by another customer yet
    • available means: in stock but ordered by another customer, so available, but not saleable.

    You could try to validate this by placing an order for a product. And doing the same check as you already did. This should cause a difference between the amount of available products and the amount of saleable products.

    Edit: More info here:

    https://blog.magestore.com/magento-multi-source-inventory-msi/#a3

提交回复
热议问题