Different between “Create” and “get” in magento 2 :

Before understanding the “create” & “get” in magento2 will remember the Mage::getModel() & Mage::getSingleton() in magento 1.

Magento :1
Mage::getModel() : This will return always new object for the given Model.

Mage::getSingleton() : This will check whether the given model Object is already available or not. If already exist then it return the available object else it will create a new object of the model and it will be set in registry. So whenever next time trigger will happen it will fetch the object from the available registry.

Magento : 2
In magento2 “create” & “get” is same as the workflow of getModel & getSingleton .

create() -> When you use “create” it will always create new instance of the object & return it.
get() -> When you use “get” it will try to found already any instance object is exist or not . If exist it will return it else it will create new instance for the object.

Save Water Save Life!!!

Leave a Reply