5

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 1

11

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.

2
  • 1
    Something similar here too stackoverflow.com/questions/8182009/get-product-changes
    – mbalparda
    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? Sep 25, 2019 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.