Get order Details from Magento 2 Observer Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?get order, customer, product details in observer magento 2Get Order details after order successSet custom price of product when adding to cart code not workingGet Quote from Order Success ObserverMagento 2: not able to get order details in observerMagento 2: Add a product to the cart programmaticallySet Name of quote_itemI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom OptionsGet all order details from getItems() / getAllItems() / getAllVisibleItems()

What could prevent concentrated local exploration?

Does using the Inspiration rules for character defects encourage My Guy Syndrome?

How do I deal with an erroneously large refund?

/bin/ls sorts differently than just ls

How to produce a PS1 prompt in bash or ksh93 similar to tcsh

What kind of equipment or other technology is necessary to photograph sprites (atmospheric phenomenon)

Is it OK if I do not take the receipt in Germany?

Normal Operator || T^2|| = ||T||^2

Does the Pact of the Blade warlock feature allow me to customize the properties of the pact weapon I create?

Why not use the yoke to control yaw, as well as pitch and roll?

Are Flameskulls resistant to magical piercing damage?

Does traveling In The United States require a passport or can I use my green card if not a US citizen?

Will I be more secure with my own router behind my ISP's router?

Pointing to problems without suggesting solutions

What is the evidence that custom checks in Northern Ireland are going to result in violence?

Compiling and throwing simple dynamic exceptions at runtime for JVM

Marquee sign letters

How is an IPA symbol that lacks a name (e.g. ɲ) called?

How to keep bees out of canned beverages?

Why these surprising proportionalities of integrals involving odd zeta values?

Etymology of 見舞い

Raising a bilingual kid. When should we introduce the majority language?

Will the Antimagic Field spell cause elementals not summoned by magic to dissipate?

Can this water damage be explained by lack of gutters and grading issues?



Get order Details from Magento 2 Observer



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?get order, customer, product details in observer magento 2Get Order details after order successSet custom price of product when adding to cart code not workingGet Quote from Order Success ObserverMagento 2: not able to get order details in observerMagento 2: Add a product to the cart programmaticallySet Name of quote_itemI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom OptionsGet all order details from getItems() / getAllItems() / getAllVisibleItems()



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to build a Magento 2 Order Observer in which I am trying to get the Product Details such as Product ID, Product Name, Product SKU, Product Quantity and Customer Details such as Customer ID, Customer Name, Shipping Address & Phone Number.



Below is my Observer.php



<?php

namespace MyPluginObserver;

use MagentoFrameworkEventObserverInterface;

class LogAddMessage implements ObserverInterface

protected $_logger;

public function __construct(
PsrLogLoggerInterface $logger, array $data = []
)
$this->_logger = $logger;


public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
$order_id = $order->getID();
$order_number = $order->getIncrementId();
foreach ($order->getAllItems() as $item)
$ProdustIds[] = $item->getProductId();
$ProdustSku[] = $item->getSku();
$proName[] = $item->getName(); //product name
$this->_logger->addDebug('Item Name: ' . $item->getName() . 'Item ID: ' . $item->getProductId());

$proName = json_encode($proName);
$ProdustSku = json_encode($ProdustSku);
$customerId = $order->getCustomerId();
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customer);
$address = $observer->getShippingAddress();
$address = json_encode($address);
$name = $customer->getName(); //customer name
$this->_logger->addDebug('Order ID: ' . $order_id . ', Products: ' . $proName . ', SKU: ' . $ProdustSku . ', Customer ID: ' . $customerId . ', Customer Name: ' . $name . 'Address: ' . $address);





On clicking Place Order in Multi Store Magento Website, magento_website_url/rest/store_code/V1/guest-carts/cart_id/payment-information gives a 500 Internal Server Error










share|improve this question
























  • Please check log exception to find more info.

    – Khoa TruongDinh
    May 24 '16 at 15:28

















0















I am trying to build a Magento 2 Order Observer in which I am trying to get the Product Details such as Product ID, Product Name, Product SKU, Product Quantity and Customer Details such as Customer ID, Customer Name, Shipping Address & Phone Number.



Below is my Observer.php



<?php

namespace MyPluginObserver;

use MagentoFrameworkEventObserverInterface;

class LogAddMessage implements ObserverInterface

protected $_logger;

public function __construct(
PsrLogLoggerInterface $logger, array $data = []
)
$this->_logger = $logger;


public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
$order_id = $order->getID();
$order_number = $order->getIncrementId();
foreach ($order->getAllItems() as $item)
$ProdustIds[] = $item->getProductId();
$ProdustSku[] = $item->getSku();
$proName[] = $item->getName(); //product name
$this->_logger->addDebug('Item Name: ' . $item->getName() . 'Item ID: ' . $item->getProductId());

$proName = json_encode($proName);
$ProdustSku = json_encode($ProdustSku);
$customerId = $order->getCustomerId();
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customer);
$address = $observer->getShippingAddress();
$address = json_encode($address);
$name = $customer->getName(); //customer name
$this->_logger->addDebug('Order ID: ' . $order_id . ', Products: ' . $proName . ', SKU: ' . $ProdustSku . ', Customer ID: ' . $customerId . ', Customer Name: ' . $name . 'Address: ' . $address);





On clicking Place Order in Multi Store Magento Website, magento_website_url/rest/store_code/V1/guest-carts/cart_id/payment-information gives a 500 Internal Server Error










share|improve this question
























  • Please check log exception to find more info.

    – Khoa TruongDinh
    May 24 '16 at 15:28













0












0








0








I am trying to build a Magento 2 Order Observer in which I am trying to get the Product Details such as Product ID, Product Name, Product SKU, Product Quantity and Customer Details such as Customer ID, Customer Name, Shipping Address & Phone Number.



Below is my Observer.php



<?php

namespace MyPluginObserver;

use MagentoFrameworkEventObserverInterface;

class LogAddMessage implements ObserverInterface

protected $_logger;

public function __construct(
PsrLogLoggerInterface $logger, array $data = []
)
$this->_logger = $logger;


public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
$order_id = $order->getID();
$order_number = $order->getIncrementId();
foreach ($order->getAllItems() as $item)
$ProdustIds[] = $item->getProductId();
$ProdustSku[] = $item->getSku();
$proName[] = $item->getName(); //product name
$this->_logger->addDebug('Item Name: ' . $item->getName() . 'Item ID: ' . $item->getProductId());

$proName = json_encode($proName);
$ProdustSku = json_encode($ProdustSku);
$customerId = $order->getCustomerId();
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customer);
$address = $observer->getShippingAddress();
$address = json_encode($address);
$name = $customer->getName(); //customer name
$this->_logger->addDebug('Order ID: ' . $order_id . ', Products: ' . $proName . ', SKU: ' . $ProdustSku . ', Customer ID: ' . $customerId . ', Customer Name: ' . $name . 'Address: ' . $address);





On clicking Place Order in Multi Store Magento Website, magento_website_url/rest/store_code/V1/guest-carts/cart_id/payment-information gives a 500 Internal Server Error










share|improve this question
















I am trying to build a Magento 2 Order Observer in which I am trying to get the Product Details such as Product ID, Product Name, Product SKU, Product Quantity and Customer Details such as Customer ID, Customer Name, Shipping Address & Phone Number.



Below is my Observer.php



<?php

namespace MyPluginObserver;

use MagentoFrameworkEventObserverInterface;

class LogAddMessage implements ObserverInterface

protected $_logger;

public function __construct(
PsrLogLoggerInterface $logger, array $data = []
)
$this->_logger = $logger;


public function execute(MagentoFrameworkEventObserver $observer)
$order = $observer->getEvent()->getOrder();
$order_id = $order->getID();
$order_number = $order->getIncrementId();
foreach ($order->getAllItems() as $item)
$ProdustIds[] = $item->getProductId();
$ProdustSku[] = $item->getSku();
$proName[] = $item->getName(); //product name
$this->_logger->addDebug('Item Name: ' . $item->getName() . 'Item ID: ' . $item->getProductId());

$proName = json_encode($proName);
$ProdustSku = json_encode($ProdustSku);
$customerId = $order->getCustomerId();
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customer);
$address = $observer->getShippingAddress();
$address = json_encode($address);
$name = $customer->getName(); //customer name
$this->_logger->addDebug('Order ID: ' . $order_id . ', Products: ' . $proName . ', SKU: ' . $ProdustSku . ', Customer ID: ' . $customerId . ', Customer Name: ' . $name . 'Address: ' . $address);





On clicking Place Order in Multi Store Magento Website, magento_website_url/rest/store_code/V1/guest-carts/cart_id/payment-information gives a 500 Internal Server Error







magento2 orders event-observer sales-order product-view






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 26 '18 at 9:43









Teja Bhagavan Kollepara

2,99241949




2,99241949










asked May 24 '16 at 14:40









Anush SwaminathanAnush Swaminathan

814




814












  • Please check log exception to find more info.

    – Khoa TruongDinh
    May 24 '16 at 15:28

















  • Please check log exception to find more info.

    – Khoa TruongDinh
    May 24 '16 at 15:28
















Please check log exception to find more info.

– Khoa TruongDinh
May 24 '16 at 15:28





Please check log exception to find more info.

– Khoa TruongDinh
May 24 '16 at 15:28










2 Answers
2






active

oldest

votes


















3














check your below line



$customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customer);


It should be



$customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customerId);


If not solved with this, Post your support log here.



You can see address with



$addressObj = $order->getBillingAddress();

echo '<pre>'; print_r($addressObj);


For Telephone, Try this



$addressObj = $order->getBillingAddress();
$to = $addressObj->getTelephone();





share|improve this answer

























  • also $name = $customer->getName(); //customer name should be $name = $customer->getFirstName().' '.$customer->getLastName(); //customer name

    – Pallavi
    May 26 '16 at 11:56












  • I realised this mistake after checking exception.log file. I made the changes and I am able to get the Customer name, but I am still not able to get the customer Address and Phone Number. @Pallavi thanks for your help

    – Anush Swaminathan
    May 27 '16 at 17:10












  • @Anush, Updated my answer. Try that. Hope that helps

    – Pallavi
    Jun 6 '16 at 9:02


















0














Hope it's helpful



 public function __construct
(
MagentoSalesModelOrder $order
)
$this->order = $order;
public function execute(MagentoFrameworkEventObserver $observer)
{
$orderId = $observer->getEvent()->getOrderIds();
$order = $this->order->load($orderId);
$orderid=$order->getEntityId();

/*get customer details*/

$custLastName= $orders->getCustomerLastname();
$custFirsrName= $orders->getCustomerFirstname();
$ipaddress=$order->getRemoteIp();
$customer_email=$order->getCustomerEmail();
$customerid=$order->getCustomerId();

/* get Billing details */
$billingaddress=$order->getBillingAddress();
$billingcity=$billingaddress->getCity();
$billingstreet=$billingaddress->getStreet();
$billingpostcode=$billingaddress->getPostcode();
$billingtelephone=$billingaddress->getTelephone();
$billingstate_code=$billingaddress->getRegionCode();

/* get shipping details */

$shippingaddress=$order->getShippingAddress();
$shippingcity=$shippingaddress->getCity();
$shippingstreet=$shippingaddress->getStreet();
$shippingpostcode=$shippingaddress->getPostcode();
$shippingtelephone=$shippingaddress->getTelephone();
$shippingstate_code=$shippingaddress->getRegionCode();

/* get total */

$tax_amount=$order->getTaxAmount();
$total=$order->getGrandTotal();





share|improve this answer

























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f116753%2fget-order-details-from-magento-2-observer%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    check your below line



    $customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customer);


    It should be



    $customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customerId);


    If not solved with this, Post your support log here.



    You can see address with



    $addressObj = $order->getBillingAddress();

    echo '<pre>'; print_r($addressObj);


    For Telephone, Try this



    $addressObj = $order->getBillingAddress();
    $to = $addressObj->getTelephone();





    share|improve this answer

























    • also $name = $customer->getName(); //customer name should be $name = $customer->getFirstName().' '.$customer->getLastName(); //customer name

      – Pallavi
      May 26 '16 at 11:56












    • I realised this mistake after checking exception.log file. I made the changes and I am able to get the Customer name, but I am still not able to get the customer Address and Phone Number. @Pallavi thanks for your help

      – Anush Swaminathan
      May 27 '16 at 17:10












    • @Anush, Updated my answer. Try that. Hope that helps

      – Pallavi
      Jun 6 '16 at 9:02















    3














    check your below line



    $customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customer);


    It should be



    $customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customerId);


    If not solved with this, Post your support log here.



    You can see address with



    $addressObj = $order->getBillingAddress();

    echo '<pre>'; print_r($addressObj);


    For Telephone, Try this



    $addressObj = $order->getBillingAddress();
    $to = $addressObj->getTelephone();





    share|improve this answer

























    • also $name = $customer->getName(); //customer name should be $name = $customer->getFirstName().' '.$customer->getLastName(); //customer name

      – Pallavi
      May 26 '16 at 11:56












    • I realised this mistake after checking exception.log file. I made the changes and I am able to get the Customer name, but I am still not able to get the customer Address and Phone Number. @Pallavi thanks for your help

      – Anush Swaminathan
      May 27 '16 at 17:10












    • @Anush, Updated my answer. Try that. Hope that helps

      – Pallavi
      Jun 6 '16 at 9:02













    3












    3








    3







    check your below line



    $customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customer);


    It should be



    $customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customerId);


    If not solved with this, Post your support log here.



    You can see address with



    $addressObj = $order->getBillingAddress();

    echo '<pre>'; print_r($addressObj);


    For Telephone, Try this



    $addressObj = $order->getBillingAddress();
    $to = $addressObj->getTelephone();





    share|improve this answer















    check your below line



    $customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customer);


    It should be



    $customer = $objectManager->create('MagentoCustomerModelCustomer')->load($customerId);


    If not solved with this, Post your support log here.



    You can see address with



    $addressObj = $order->getBillingAddress();

    echo '<pre>'; print_r($addressObj);


    For Telephone, Try this



    $addressObj = $order->getBillingAddress();
    $to = $addressObj->getTelephone();






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 6 '16 at 9:12









    Raphael at Digital Pianism

    55.3k22124281




    55.3k22124281










    answered May 26 '16 at 11:55









    PallaviPallavi

    30918




    30918












    • also $name = $customer->getName(); //customer name should be $name = $customer->getFirstName().' '.$customer->getLastName(); //customer name

      – Pallavi
      May 26 '16 at 11:56












    • I realised this mistake after checking exception.log file. I made the changes and I am able to get the Customer name, but I am still not able to get the customer Address and Phone Number. @Pallavi thanks for your help

      – Anush Swaminathan
      May 27 '16 at 17:10












    • @Anush, Updated my answer. Try that. Hope that helps

      – Pallavi
      Jun 6 '16 at 9:02

















    • also $name = $customer->getName(); //customer name should be $name = $customer->getFirstName().' '.$customer->getLastName(); //customer name

      – Pallavi
      May 26 '16 at 11:56












    • I realised this mistake after checking exception.log file. I made the changes and I am able to get the Customer name, but I am still not able to get the customer Address and Phone Number. @Pallavi thanks for your help

      – Anush Swaminathan
      May 27 '16 at 17:10












    • @Anush, Updated my answer. Try that. Hope that helps

      – Pallavi
      Jun 6 '16 at 9:02
















    also $name = $customer->getName(); //customer name should be $name = $customer->getFirstName().' '.$customer->getLastName(); //customer name

    – Pallavi
    May 26 '16 at 11:56






    also $name = $customer->getName(); //customer name should be $name = $customer->getFirstName().' '.$customer->getLastName(); //customer name

    – Pallavi
    May 26 '16 at 11:56














    I realised this mistake after checking exception.log file. I made the changes and I am able to get the Customer name, but I am still not able to get the customer Address and Phone Number. @Pallavi thanks for your help

    – Anush Swaminathan
    May 27 '16 at 17:10






    I realised this mistake after checking exception.log file. I made the changes and I am able to get the Customer name, but I am still not able to get the customer Address and Phone Number. @Pallavi thanks for your help

    – Anush Swaminathan
    May 27 '16 at 17:10














    @Anush, Updated my answer. Try that. Hope that helps

    – Pallavi
    Jun 6 '16 at 9:02





    @Anush, Updated my answer. Try that. Hope that helps

    – Pallavi
    Jun 6 '16 at 9:02













    0














    Hope it's helpful



     public function __construct
    (
    MagentoSalesModelOrder $order
    )
    $this->order = $order;
    public function execute(MagentoFrameworkEventObserver $observer)
    {
    $orderId = $observer->getEvent()->getOrderIds();
    $order = $this->order->load($orderId);
    $orderid=$order->getEntityId();

    /*get customer details*/

    $custLastName= $orders->getCustomerLastname();
    $custFirsrName= $orders->getCustomerFirstname();
    $ipaddress=$order->getRemoteIp();
    $customer_email=$order->getCustomerEmail();
    $customerid=$order->getCustomerId();

    /* get Billing details */
    $billingaddress=$order->getBillingAddress();
    $billingcity=$billingaddress->getCity();
    $billingstreet=$billingaddress->getStreet();
    $billingpostcode=$billingaddress->getPostcode();
    $billingtelephone=$billingaddress->getTelephone();
    $billingstate_code=$billingaddress->getRegionCode();

    /* get shipping details */

    $shippingaddress=$order->getShippingAddress();
    $shippingcity=$shippingaddress->getCity();
    $shippingstreet=$shippingaddress->getStreet();
    $shippingpostcode=$shippingaddress->getPostcode();
    $shippingtelephone=$shippingaddress->getTelephone();
    $shippingstate_code=$shippingaddress->getRegionCode();

    /* get total */

    $tax_amount=$order->getTaxAmount();
    $total=$order->getGrandTotal();





    share|improve this answer





























      0














      Hope it's helpful



       public function __construct
      (
      MagentoSalesModelOrder $order
      )
      $this->order = $order;
      public function execute(MagentoFrameworkEventObserver $observer)
      {
      $orderId = $observer->getEvent()->getOrderIds();
      $order = $this->order->load($orderId);
      $orderid=$order->getEntityId();

      /*get customer details*/

      $custLastName= $orders->getCustomerLastname();
      $custFirsrName= $orders->getCustomerFirstname();
      $ipaddress=$order->getRemoteIp();
      $customer_email=$order->getCustomerEmail();
      $customerid=$order->getCustomerId();

      /* get Billing details */
      $billingaddress=$order->getBillingAddress();
      $billingcity=$billingaddress->getCity();
      $billingstreet=$billingaddress->getStreet();
      $billingpostcode=$billingaddress->getPostcode();
      $billingtelephone=$billingaddress->getTelephone();
      $billingstate_code=$billingaddress->getRegionCode();

      /* get shipping details */

      $shippingaddress=$order->getShippingAddress();
      $shippingcity=$shippingaddress->getCity();
      $shippingstreet=$shippingaddress->getStreet();
      $shippingpostcode=$shippingaddress->getPostcode();
      $shippingtelephone=$shippingaddress->getTelephone();
      $shippingstate_code=$shippingaddress->getRegionCode();

      /* get total */

      $tax_amount=$order->getTaxAmount();
      $total=$order->getGrandTotal();





      share|improve this answer



























        0












        0








        0







        Hope it's helpful



         public function __construct
        (
        MagentoSalesModelOrder $order
        )
        $this->order = $order;
        public function execute(MagentoFrameworkEventObserver $observer)
        {
        $orderId = $observer->getEvent()->getOrderIds();
        $order = $this->order->load($orderId);
        $orderid=$order->getEntityId();

        /*get customer details*/

        $custLastName= $orders->getCustomerLastname();
        $custFirsrName= $orders->getCustomerFirstname();
        $ipaddress=$order->getRemoteIp();
        $customer_email=$order->getCustomerEmail();
        $customerid=$order->getCustomerId();

        /* get Billing details */
        $billingaddress=$order->getBillingAddress();
        $billingcity=$billingaddress->getCity();
        $billingstreet=$billingaddress->getStreet();
        $billingpostcode=$billingaddress->getPostcode();
        $billingtelephone=$billingaddress->getTelephone();
        $billingstate_code=$billingaddress->getRegionCode();

        /* get shipping details */

        $shippingaddress=$order->getShippingAddress();
        $shippingcity=$shippingaddress->getCity();
        $shippingstreet=$shippingaddress->getStreet();
        $shippingpostcode=$shippingaddress->getPostcode();
        $shippingtelephone=$shippingaddress->getTelephone();
        $shippingstate_code=$shippingaddress->getRegionCode();

        /* get total */

        $tax_amount=$order->getTaxAmount();
        $total=$order->getGrandTotal();





        share|improve this answer















        Hope it's helpful



         public function __construct
        (
        MagentoSalesModelOrder $order
        )
        $this->order = $order;
        public function execute(MagentoFrameworkEventObserver $observer)
        {
        $orderId = $observer->getEvent()->getOrderIds();
        $order = $this->order->load($orderId);
        $orderid=$order->getEntityId();

        /*get customer details*/

        $custLastName= $orders->getCustomerLastname();
        $custFirsrName= $orders->getCustomerFirstname();
        $ipaddress=$order->getRemoteIp();
        $customer_email=$order->getCustomerEmail();
        $customerid=$order->getCustomerId();

        /* get Billing details */
        $billingaddress=$order->getBillingAddress();
        $billingcity=$billingaddress->getCity();
        $billingstreet=$billingaddress->getStreet();
        $billingpostcode=$billingaddress->getPostcode();
        $billingtelephone=$billingaddress->getTelephone();
        $billingstate_code=$billingaddress->getRegionCode();

        /* get shipping details */

        $shippingaddress=$order->getShippingAddress();
        $shippingcity=$shippingaddress->getCity();
        $shippingstreet=$shippingaddress->getStreet();
        $shippingpostcode=$shippingaddress->getPostcode();
        $shippingtelephone=$shippingaddress->getTelephone();
        $shippingstate_code=$shippingaddress->getRegionCode();

        /* get total */

        $tax_amount=$order->getTaxAmount();
        $total=$order->getGrandTotal();






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 days ago

























        answered Mar 21 at 9:15









        ARUNPRABAKARAN MARUNPRABAKARAN M

        536114




        536114



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f116753%2fget-order-details-from-magento-2-observer%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form