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

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


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


isSeable() looks like it's checking if it reaches 0

isAvailable() looks like it's counting


I see those having semantic differences. An item that is not in stock can still be saleable if said item is set to allow backorders.

As far as I can tell, it looks like isAvailable checks a product type instance to see if the product type could be for sale if it is indeed available.

So, to venture a guess at when you might choose one over the other:

If you are checking an individual product to see if said product is actually ready for sale, you should use isSalable(), as it will call isAvailable().

To check if a product (whose type you don't know off hand) could be sold, and I suppose skipping the step of checking the product's type, you could call isAvailable() on the product.

isAvailable() checks if a product's type is salable.

isSalable() checks if a product is salable.

isSaleable() is an alias of isSalable().