Is there any possibility to get attribute data difference between model versions? I create observer for catalog_product_save_after
action, and now i want to make some changes only if attribute product_versions
has changed.
1 Answer
Try this:
$newValue = $product->getData('product_versions');
$oldValue = $product->getOrigData('product_versions');
Now check if the 2 values are different. If they are, do your magic.
-
1Something similar here too stackoverflow.com/questions/8182009/get-product-changes Commented Aug 5, 2014 at 11:14
-
@Marius, What if I don't have any specific attribute to compare? I need to compare if any data has been changed or not? As I see it wont be better way to compare both giant arrays
$product->getData()
and$product->getOrigData()
. Please can you suggest any different way? Commented Sep 25, 2019 at 8:08