I want to add a page by the controller, I have set the routes and controller files according to the guideline. However, it still cant show the page.
app/code/Mymodule/OrderController/Controller/Page/View.php
<?php
namespace MymoduleOrderControllerControllerPage;
use MagentoSalesModelResourceModelOrderCollectionFactory;
use MagentoFrameworkControllerResultJsonFactory;
use MagentoFrameworkAppActionContext;
class View extends MagentoFrameworkAppActionAction {
protected $jsonFactory;
protected $collectionFactory;
public function __construct(
Context $context,
JsonFactory $jsonFactory,
CollectionFactory $collectionFactory
)
{
$this->jsonFactory=$jsonFactory;
$this->collectionFactory=$collectionFactory;
parent::__construct($context);
}
public function execute()
{
// TODO: Implement execute() method.
$collcection = $this->collectionFactory->create()->addAttributeToSelect('*')->getData();
$result = $this->jsonFactory->create();
$data = ['object'=>$collcection];
return $result->setData($data);
}
}
app/code/Mymodule/OrderController/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="standard2">
<route frontName="ordercontroller" id="ordercontroller">
<module name="Mymodule_OrderController"/>
</route>
</router>
I am using Luma theme as the base and it just showed can’t find the page when I access “https://xxxxxx.com/ordercontroller/page/view”