I want to change the landing page for a customer who has an active session to their customer/account page. I set up a conditional in aroundExecute() in app/code/MYNAME/MODULE/Plugin/CMS/Controller/Index.php
<?php
namespace MYNAME\MODULE\Plugin\Cms\Controller\Index;
use Magento\Customer\Model\Session;
class Index
{
/**
* @var Session
*/
protected $session;
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $objectManager;
/**
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param Session $customerSession
*/
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManager,
Session $customerSession
) {
$this->objectManager = $objectManager;
$this->session = $customerSession;
}
/**
* Renders CMS Home page
*
* @param string|null $coreRoute
* @return \Magento\Framework\Controller\Result\Forward
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundExecute(
\Magento\Cms\Controller\Index\Index $subject,
\Closure $proceed,
$coreRoute = null
) {
if ($this->session->isLoggedIn()) {
$pageId = 5;
return $this->objectManager->get('Magento\Cms\Helper\Page')->prepareResultPage($subject, $pageId);
}
return $proceed($coreRoute);
}
}
It works great as long as you know the $pageId (Its randomly set to 5 above). However, I cannot find the pageId for the Customer Account page. I can't find anything in the Magento docs nor anywhere online. The examples I have found return pageId for every page I create but returns nothing for pages generated by Magento. What is the pageId? Or is there a better way to approach this problem?