When i printed this print_r(get_class($this->getOrder())); I got this class name


What does this actually mean ? Where is this "Magento\Sales\Model\Order\Interceptor" class ?

Any thoughts ?

  • Any thoughts on this ?
    – devhs
    Mar 20 at 10:43

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.

  • Thankyou very much for the answer, is their any way we can check from where did this Magento/Sales/Model/Order/Interceptor.php. is generated ?
    – devhs
    Mar 20 at 11:04
  • 1
    hey there! Check the link form my answer it also mentions where and when the classes are generated, a brief extract "As for the actual generation, Magento handles this with a PHP autoloader. If a developer instantiates a class (or otherwise triggers a PHP autoload event with a class name (in a type hint, class_exists class, etc), and the composer based autoloader can't find the class file, a second registered autoloader Magento\Framework\Code\Generator\Autoloader::load is triggered. " Mar 20 at 11:08
  • Thankyou for the explanation
    – devhs
    Mar 20 at 11:10
  • 1
    you are most welcome! Mar 20 at 13:27

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.