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.

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"/>


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.


Controller of your module has to extend Magento\Catalog\Controller\Category\View

Also, instead of copypasting layout file use handle update and use references to change parameters of blocks.

  • Ah okay, so what would I make the handle update be in this case? catalog_category_view? – Metropolis Jan 17 '18 at 16:06
  • I think I got it close, but I am getting a 404 error on the view now. – Metropolis Jan 17 '18 at 17:03
  • @Metropolis do you have frontend router set up? – czs Jan 18 '18 at 11:53
  • Yes, its working fine, until I change the controller parent. I basically just created a blank class that is extending from \Magento\Catalog\Controller\Category\View. I basically want it to reuse the constructor and the execute function from the parent I would assume. So I think that may be why I am getting the 404. I may need to do something more inside the execute function of the child. – Metropolis Jan 18 '18 at 18:43
  • @Metropolis that's propably the case since execute method of Category View controller is checking request for parameter and checks if it points to correct category - if not then it redirects to 404. – czs Jan 19 '18 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.