Categories


Archives


Recent Posts


Categories


Magento 2 Varient_Object — no more _construct

astorm

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'
Block/Abstract.php
160:        $this->_construct();

Controller/Varien/Action.php
146:        $this->_construct();

Model/Abstract.php
147:        $this->_construct();

Model/Resource/Abstract.php
49:        $this->_construct();

Model/Resource/Db/Collection/Abstract.php
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 © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 23rd September 2013

email hidden; JavaScript is required