I try to get status of stock but i get this error message:
Fatal error: Call to a member function getIsInStock() on null with
$stockProduct = $product->getStockItem()->getIsInStock();
I got this error message when i try to create a new product.
I'm using observer: catalog_product_save_after
Best Answer
You can really use this event
catalog_product_save_after
and you do something like this:The collection :
Nb: We can't get stock directly from product, you need an join.