Let’s initiate a discussion!!
1 |
<preference for="Magento\Catalog\Block\Category\View" type="Vendor\Module\Block\Category\View"/> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
<?php namespace Vendor\Module\Block\Category; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\Category; class View extends \Magento\Catalog\Block\Category\View { protected $_urlInterface; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Catalog\Model\Layer\Resolver $layerResolver, \Magento\Framework\Registry $registry, \Magento\Catalog\Helper\Category $categoryHelper, \Magento\Framework\UrlInterface $urlInterface, array $data = [] ) { $this->_urlInterface = $urlInterface; $this->_categoryHelper = $categoryHelper; $this->_catalogLayer = $layerResolver->get(); $this->_coreRegistry = $registry; parent::__construct($context, $layerResolver, $registry, $categoryHelper, $data); } protected function _prepareLayout() { parent::_prepareLayout(); $this->getLayout()->createBlock(\Magento\Catalog\Block\Breadcrumbs::class); $category = $this->getCurrentCategory(); if ($category) { $title = $category->getMetaTitle(); if ($title) { $this->pageConfig->getTitle()->set($title); } $description = $category->getMetaDescription(); if ($description) { $this->pageConfig->setDescription($description); } $keywords = $category->getMetaKeywords(); if ($keywords) { $this->pageConfig->setKeywords($keywords); } if ($this->_categoryHelper->canUseCanonicalTag()) { $this->pageConfig->addRemotePageAsset( $category->getUrl(), 'canonical', ['attributes' => ['rel' => 'canonical']] ); } $pageMainTitle = $this->getLayout()->getBlock('page.main.title'); if ($pageMainTitle) { $pageMainTitle->setPageTitle($this->getCurrentCategory()->getName()); } } return $this; } } |
[crayon-641fafb45b534678263391/] Using above fucntion Images can be imported directly from...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
We will create a new category page layout and use...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.