How can I get current order’s payment method and application_no in order view in Admin?

I want to display application_no if payment method is FN in order details page.

I have created a block.

class Custom extends MagentoFrameworkViewElementTemplate
{
    public function __construct(
        MagentoFrameworkViewElementTemplateContext $context,
         array $data = []
    ) {
        parent::__construct($context, $data);
    }

    // public function getOrderId(){
    //     return $orderId = $this->getRequest()->getParam('order_id');
    // }

    public function getPaymentMethod(){
        // $orderId = $this->getRequest()->getParam('order_id');
        // $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        // $order = $objectManager->create('MagentoSalesModelOrder')->loadByIncrementId($orderId);
        // $payment = $order->getPayment();
        // // $method = $payment->getMethodInstance();
        // // $methodTitle = $method->getTitle();
        // return $order;
    }
}

Also, I have created a sales_order_view.xml to display my application_no (Tested it with static value and working fine).

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="left">
           <referenceContainer name="payment_additional_info">
                <block class="LimesharpFinanceNowBlockAdminhtmlOrderViewCustom" name="sales_order_view_custom" template="order/view/custom.phtml" />
             </referenceContainer>
        </referenceContainer>
    </body>
</page>

Here is my view file –

FN: <?php var_dump($block->getPaymentMethod()); ?>

Now I wanna pass application_no(custom column already in sales_order table) and payment_method. How can I pass this information from block to view of current order and display it conditionally?


Go to Source of this post
Author Of this post: Abhishek Honrao
Title Of post: How can I get current order’s payment method and application_no in order view in Admin?
Author Link: {authorlink}