Magento 2: Class instance
-
15-04-2021 - |
Question
When i printed this print_r(get_class($this->getOrder()));
I got this class name
Magento\Sales\Model\Order\Interceptor
What does this actually mean ?
Where is this "Magento\Sales\Model\Order\Interceptor
" class ?
Any thoughts ?
La solution
Interceptor classes are used in the implementation of the plugin mechanism in Magento 2.
These classes are automatically generated when you run bin/magento setup:di:compile
and you will find them in the 'generated' folder of your Magento installation. In your particular case, this means you will find your physical file as <magento_root_folder>/generated/code/Magento/Sales/Model/Order/Interceptor.php.
Please read Alan Storm's answer on https://magento.stackexchange.com/a/124355/35330 for a detailed grasp on the term.