Recent Posts


Magento 2 Varient_Object — no more _construct


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

In Magento 2, the base Varien_Object class no longer has a custom, internal _construct method. Blocks, Controllers, Models, Resource Models, and Collections still have an internal _construct, but that’s because the core team defined _construct methods on the various abstract base classes for those objects.

$ ack '->_construct'
160:        $this->_construct();

146:        $this->_construct();

147:        $this->_construct();

49:        $this->_construct();

133:        $this->_construct();

If you’ve created any custom classes with a _construct method that extends from the base Varient_Object class (or one of the many Magento 1 classes that extends from Varient_Object), you’ll need to do a little refactoring for Magento 2.

Copyright © Alan Storm 1975 – 2022 All Rights Reserved

Originally Posted: 23rd September 2013