0

How to get entity_id of created custom address after executing of customer_address_save_after event

  private function getEntityId($observer)
  {
        $customerAddress = $observer->getCustomerAddress();
        $entityId = $customerAddress->getCustomer()->getEntityId();
        return $entityId; //entity_id of the customer_entity table
  }

This method returns the entity_id of the customer_entity table, but I need the entity_id of the customer_address_entity table

2 Answers 2

1

You can get the address id as given below.

$customerAddress = $observer->getCustomerAddress();
$addressId = $customerAddress->getId();
2
  • not working for me
    – matinict
    Commented Sep 5, 2018 at 11:41
  • May be you are getting the wrong address object. Try to print the address data by $customerAddress->getData() and check. Commented Sep 5, 2018 at 11:53
0

Try :

$event = $observer->getEvent();
$customer = $event->getCustomer();
$addresses = $customer->getAddresses(); //array

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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