66namespace Magento \Catalog \Block \Category ;
77
88/**
9- * Class View
9+ * Category View Block class
1010 * @api
11- * @package Magento\Catalog\Block\Category
1211 * @since 100.0.2
1312 */
1413class View extends \Magento \Framework \View \Element \Template implements \Magento \Framework \DataObject \IdentityInterface
1514{
1615 /**
17- * Core registry
18- *
1916 * @var \Magento\Framework\Registry
2017 */
2118 protected $ _coreRegistry = null ;
2219
2320 /**
24- * Catalog layer
25- *
2621 * @var \Magento\Catalog\Model\Layer
2722 */
2823 protected $ _catalogLayer ;
@@ -32,40 +27,56 @@ class View extends \Magento\Framework\View\Element\Template implements \Magento\
3227 */
3328 protected $ _categoryHelper ;
3429
30+ /**
31+ * @var \Magento\Catalog\Helper\Data|null
32+ */
33+ private $ catalogData ;
34+
3535 /**
3636 * @param \Magento\Framework\View\Element\Template\Context $context
3737 * @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
3838 * @param \Magento\Framework\Registry $registry
3939 * @param \Magento\Catalog\Helper\Category $categoryHelper
4040 * @param array $data
41+ * @param \Magento\Catalog\Helper\Data|null $catalogData
4142 */
4243 public function __construct (
4344 \Magento \Framework \View \Element \Template \Context $ context ,
4445 \Magento \Catalog \Model \Layer \Resolver $ layerResolver ,
4546 \Magento \Framework \Registry $ registry ,
4647 \Magento \Catalog \Helper \Category $ categoryHelper ,
47- array $ data = []
48+ array $ data = [],
49+ \Magento \Catalog \Helper \Data $ catalogData = null
4850 ) {
4951 $ this ->_categoryHelper = $ categoryHelper ;
5052 $ this ->_catalogLayer = $ layerResolver ->get ();
5153 $ this ->_coreRegistry = $ registry ;
54+ $ this ->catalogData = $ catalogData ?? \Magento \Framework \App \ObjectManager::getInstance ()
55+ ->get (\Magento \Catalog \Helper \Data::class);
5256 parent ::__construct ($ context , $ data );
5357 }
5458
5559 /**
60+ * @inheritdoc
5661 * @return $this
5762 */
5863 protected function _prepareLayout ()
5964 {
6065 parent ::_prepareLayout ();
6166
62- $ this ->getLayout ()->createBlock (\Magento \Catalog \Block \Breadcrumbs::class);
67+ $ block = $ this ->getLayout ()->createBlock (\Magento \Catalog \Block \Breadcrumbs::class);
6368
6469 $ category = $ this ->getCurrentCategory ();
6570 if ($ category ) {
6671 $ title = $ category ->getMetaTitle ();
6772 if ($ title ) {
6873 $ this ->pageConfig ->getTitle ()->set ($ title );
74+ } else {
75+ $ title = [];
76+ foreach ($ this ->catalogData ->getBreadcrumbPath () as $ breadcrumb ) {
77+ $ title [] = $ breadcrumb ['label ' ];
78+ }
79+ $ this ->pageConfig ->getTitle ()->set (join ($ block ->getTitleSeparator (), array_reverse ($ title )));
6980 }
7081 $ description = $ category ->getMetaDescription ();
7182 if ($ description ) {
@@ -93,6 +104,8 @@ protected function _prepareLayout()
93104 }
94105
95106 /**
107+ * Return Product list html
108+ *
96109 * @return string
97110 */
98111 public function getProductListHtml ()
@@ -114,6 +127,8 @@ public function getCurrentCategory()
114127 }
115128
116129 /**
130+ * Return CMS block html
131+ *
117132 * @return mixed
118133 */
119134 public function getCmsBlockHtml ()
@@ -131,6 +146,7 @@ public function getCmsBlockHtml()
131146
132147 /**
133148 * Check if category display mode is "Products Only"
149+ *
134150 * @return bool
135151 */
136152 public function isProductMode ()
@@ -140,6 +156,7 @@ public function isProductMode()
140156
141157 /**
142158 * Check if category display mode is "Static Block and Products"
159+ *
143160 * @return bool
144161 */
145162 public function isMixedMode ()
@@ -149,6 +166,7 @@ public function isMixedMode()
149166
150167 /**
151168 * Check if category display mode is "Static Block Only"
169+ *
152170 * For anchor category with applied filter Static Block Only mode not allowed
153171 *
154172 * @return bool
0 commit comments