Originally I was trying to copy over all of the xml from vendor/magento/module-catalog/view/frontend/layout/catalog_category_view.xml
into my own xml file. This route was not working.
So I have now changed to where I am extending my controller from \Magento\Catalog\Controller\Category\View
.
<?php
namespace My\Custom\Controller\ProductGrid;
use Magento\Framework\App\Action\Context;
use Magento\Catalog\Model\Design;
use Magento\Catalog\Model\Session;
use Magento\Framework\Registry;
use Magento\Store\Model\StoreManagerInterface;
use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\Controller\Result\ForwardFactory;
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Model\Layer\Resolver;
/**
* Class HeaderA
* @package My\Custom\Controller\Header
*/
class ProductGridA extends \Magento\Catalog\Controller\Category\View
{
/**
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page
*/
public function execute()
{
return parent::execute();
}
}
And then inside my xml file I have
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="catalog_category_view"/>
<body>
</body>
</page>
My page is loading, but the content is coming out blank. I believe I need to set a category to be pulled up somehow but I can not figure out the best way to do this.