0

I have create one module which add 'location_id' in 'customer_address_entity' table. I also create one observer which called when order placed. Here i got the address id from order, Now i want to fetch the value which is set to 'location_id' on my observer from address id.

how can i do that?

Thanks

  • From which model location_id is set? – Ashish Viradiya Dec 14 '18 at 12:03
0

Try this:

<?php
namespace VendorName\Hello\Observer;

use Magento\Framework\Event\ObserverInterface;

class orderSaveAfter implements ObserverInterface
{
    /**
     * @var addressFactory
     */
    protected $_addressFactory;

    /**
     * @param \Magento\Customer\Model\AddressFactory $addressFactory
     */
    public function __construct(
        \Magento\Customer\Model\AddressFactory $addressFactory

    ) {
         $this->_addressFactory = $addressFactory;
    }

    /**
     * customer register event handler
     *
     * @param \Magento\Framework\Event\Observer $observer
     * @return void
     */
    public function execute(\Magento\Framework\Event\Observer $observer)
    {

        $addressId = 111;
        $address = $this->_addressFactory->create()->load($addressId);
        echo "<pre>";print_r($address->getData());exit;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.