I have below code. Which give same result either I use create
or get
$orderId = 1;
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$this->orderPayment = $_objectManager->create('Magento\Sales\Api\Data\OrderPaymentInterface')->load($orderId);
$this->orderPayment = $_objectManager->get('Magento\Sales\Api\Data\OrderPaymentInterface')->load($orderId);
echo $this->orderPayment->getLastTransId();
So What is exactly difference between them? Which needs to be used & when?
Best Answer
If you take a look at class Magento\Framework\ObjectManager\ObjectManager, you'll notice this block: