Plugins for magic getters/setters

Is that even possible?

Yes.

How can I pluginize the magic getters/setters in magento 2?

In the same way as a other public method. You need to declare plugin in di.xml configuration and add you custom code in plugin.

public function before__call(\Magento\Review\Model\Review $review, $method, $args)
{
    if ($method == 'setStatusId') {
        if (isset($args[0])) {
            $args[0] = \Magento\Review\Model\Review::STATUS_APPROVED;
            return [$method, $args];
        }
    }
    //leave everything unchanged
    return null;
}

But pluginization of DTO classes is not good idea. Try to customize appropriate controllers/services for modify application behaviour and do not add plugins on DTO object. This customization will destroy application layers. I understand, that you are use most quick and easy way, but in some case it is wrong strategy.


I once had a similar problem. I ended up with pluginize the setData()-method, although in my opinion that generates a tremendous waste of resources... :-(