3

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.

7

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.

  • Something similar here too stackoverflow.com/questions/8182009/get-product-changes – mbalparda Aug 5 '14 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? – Sarvesh Ahuja Sep 25 '19 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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