Get product changes

后端 未结 3 1205
难免孤独
难免孤独 2021-02-14 00:33

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

3条回答
  •  南笙
    南笙 (楼主)
    2021-02-14 01:11

    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.

提交回复
热议问题