-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Description
I want to add my actions to customer/
route. Example (URL Route Sharing).
Steps to reproduce
- Create a module
CustomerSurvey
. - Create a controller
MyVendor\CustomerSurvey\Controller\Survey\Test
- Create a controller
MyVendor\CustomerSurvey\Controller\Survey\My\Test
- Create a
routes.xml
. - Go to http://example.com/customer/survey/test.
- Go to http://example.com/customer/survey/my/test.
etc/frontend/routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="survey" frontName="survey">
<module name="MyVendor_CustomerSurvey"/>
</route>
<route id="customer">
<module name="MyVendor_CustomerSurvey" after="Magento_Customer"/>
</route>
</router>
</config>
Example of controller
<?php
namespace MyVendor\CustomerSurvey\Controller\Survey;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
class Test extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory resultPageFactory
*/
public function __construct(
Context $context, PageFactory $resultPageFactory
)
{
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
/**
* Default customer account page
*
* @return void
*/
public function execute()
{
echo 1;
exit;
//return $this->resultPageFactory->create();
}
}
Actual result
- http://example.com/customer/survey/test - working.
- http://example.com/customer/survey/my/test - not working (404).
What is permissible level of nesting for the controller?
Q | A |
---|---|
Magento version | 2.1.2 with sample data |
PHP version | 7 x64 |
Operating system | Windows 10 x64 |
Metadata
Metadata
Assignees
Labels
No labels