I want to change the condition that redirect you to customer/address/new if you want to see your address book. I just want to open the address book empty without force users to add a new address in order to see the page. But can not find where change that condition in my files.

1 Answer 1


You can try the steps below.

Assume you are using a custom module names "Company_MyModule"

Step 1)

Create di.xml under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc

File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Customer\Controller\Address\Index" type="Company\MyModule\Controller\Address\Index" />                    

step 2)

Create the controller file Index.php under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Controller/Address

File : YOUR-MAGENTO-ROOT/app/code/Company/MyModule/Controller/Address/index.php


namespace Company\MyModule\Controller\Address; 

class Index extends \Magento\Customer\Controller\Address\Index

   public function execute()

        $addresses = $this->customerRepository->getById($this->_getSession()->getCustomerId())->getAddresses();
        //if (count($addresses)) {
            /** @var \Magento\Framework\View\Result\Page $resultPage */
            $resultPage = $this->resultPageFactory->create();
            $block = $resultPage->getLayout()->getBlock('address_book');
            if ($block) {
            return $resultPage;



step 3)

Run Di compile

sudo php bin/magento setup:di:compile

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.