#StackBounty: #magento2 #meta-title Setting Meta Title on Product List Page

Bounty: 100

I’ve been trying to set the meta title of a product listing page when an action is executed. I found this post on Magento2 StackExchange and tried to replicate in my Controller:

    namespace TreyBakeGarageControllerIndex;

    use MagentoFrameworkAppActionContext;

    class Search extends MagentoFrameworkAppActionAction
        protected $resultPageFactory;
        protected $_pageConfig;

        public function __construct(
            Context $context,
            MagentoFrameworkViewResultPageFactory $resultPageFactory,
            MagentoFrameworkViewPageConfig $pageConfig
            $this->resultPageFactory = $resultPageFactory;
            $this->_pageConfig = $pageConfig;


        protected function _prepareLayout()
            $pmt = $this->getLayout()->getBlock('page.main.title');

            return parent::_prepareLayout();

        public function execute()
            # my controller exec code

            $rpf = $this->resultPageFactory->create();
            $pmt = $rpf->getLayout()->getBlock('page.main.title');

            # etc.

Disabling one at a time makes no change, and both uncommented has no affect. What am I doing wrong and how can I override the meta title (<title>) for product listing pages using $_GET params (though, really, if I know how to set the meta title correctly, I can fill in the blanks with $_GET)?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.