In account pages when I click on address book on left side panel it redirect to add new address form with url customer/address/new/
while , In actual I should go to index where I can see address in address book.
Why its happening any idea ?
In account pages when I click on address book on left side panel it redirect to add new address form with url customer/address/new/
while , In actual I should go to index where I can see address in address book.
Why its happening any idea ?
Redirecting on New Address Form, When user don't have any address is default functionlity of magento. If you want to overwrite this, you need to create plugin and overwrite the default functionlity like below:
Specify new plugin
class in app/code/Stack/Customer/etc/di.xml
file using the below code:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Customer\Controller\Address\Index">
<plugin name="address-index" type="Stack\Customer\Plugin\Controller\Address\Index" sortOrder="1" />
</type>
</config>
Create plugin
file app/code/Stack/Customer/Plugin/Controller/Address/Index.php
using the below code:
namespace Stack\Customer\Plugin\Controller\Address;
class Index
{
public function __construct(
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\App\Response\RedirectInterface $redirect
)
{
$this->resultPageFactory = $resultPageFactory;
$this->_redirect = $redirect;
}
public function aroundExecute(\Magento\Customer\Controller\Address\Index $index, callable $proceed)
{
$resultPage = $this->resultPageFactory->create();
$block = $resultPage->getLayout()->getBlock('address_book');
if ($block) {
$block->setRefererUrl($this->_redirect->getRefererUrl());
}
return $resultPage;
}
}
Hope this help!!
vendor/magento/module-customer/view/frontend/templates/address/book.phtml
-- you can copy this file in your theme in customer module
Commented
Oct 3, 2017 at 6:43