Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get product changes

Tags:

magento

Situation is:

Admin logs in to system and he changes product somehow.

For example:

Sets qty to 10 Adds 2 images Changes description

Is there any way to track these changes? Well I mean exactly track WHAT and HOW admin changed?

I use Magento CE 1.6

like image 759
Jevgeni Smirnov Avatar asked Nov 18 '11 11:11

Jevgeni Smirnov


1 Answers

Yes you can find unaltered data through getOrigData() as pointed out by clockworkgeek but Magento has a build in function to compare and check if the data has been changed. The method is called dataHasChangedFor() and you have to pass the property that you want to check. It would look somthing like this.

$isChanged = $productData->dataHasChangedFor('description'); 
if ($isChanged) { 
// do somthing 
}

here the method dataHasChanged() will return boolean value based on whether the data was altered.

like image 112
Varun Desai Avatar answered Nov 06 '22 23:11

Varun Desai