Skip to content

The controller is not working #7442

@springimport

Description

@springimport

I want to add my actions to customer/ route. Example (URL Route Sharing).

Steps to reproduce

  1. Create a module CustomerSurvey.
  2. Create a controller MyVendor\CustomerSurvey\Controller\Survey\Test
  3. Create a controller MyVendor\CustomerSurvey\Controller\Survey\My\Test
  4. Create a routes.xml.
  5. Go to http://example.com/customer/survey/test.
  6. 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

  1. http://example.com/customer/survey/test - working.
  2. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions