I have a custom module in which I need to get the order details. I am using the below code to get the orders from quotes in admin end,
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$options = $objectManager->create('Magento\Quote\Model\Quote');
$_order = $options->load($_quoteId);
Here I am getting the quote and order details. I am getting the billing address In case I try to print it as below,
print_r($_order->getBillingAddress()->getStreet());
print_r($_order->getBillingAddress()->getFirstName());
However, when I am using the getFormattedAddress() like below, I don't get anything.
echo $block->getFormattedAddress($_order->getBillingAddress());
In my block I have added the getFormattedAddress() function as below,
public function getFormattedAddress(Address $address) {
return $this->addressRenderer->format($address, 'html');
}
This gives me an error as,
Uncaught TypeError: Argument 1 passed to Vendor\Module\Block\Adminhtml\Quotes::getFormattedAddress() must be an instance of Magento\Sales\Model\Order\Address, instance of Magento\Quote\Model\Quote\Address given
I tried to go through some of the belwo links but could not manage to get the solution of my problem,
The issue here is, getFormattedAddress() expects an instance of Magento\Sales\Model\Order\Address whereas, I am passing an address of Magento\Quote\Model\Quote\Address.
Is there any way to use getFormattedAddress() using the quote address?
PS: I know the using objectManager directly is not recommended and I have plans to change it once I get the billing and shipping address.
Please, can anyone help?
public function getFormattedAddress(Address $address)
– Dinesh Yadav Oct 9 '17 at 6:05