I have catalog_product_save_after observer where I want detect when product became available for sale (Magento 2.2). I'm trying to compare some attributes using this code
$old = $product->getOrigData('status'); $new = $product->getData('status');
Which attribute should I use? I was trying
- is_in_stock -> this is always empty
- quantity_and_stock_status -> old value is an array new is integer always with value 1
- status seems to work, but only after second product save. When I click save product once, new status value is always equal old value. When I click save second time (without changing anything) then status has new value.
How can I check this, maybe this is something connected with stockitem?