6
6
namespace Magento \Catalog \Block \Category ;
7
7
8
8
/**
9
- * Class View
9
+ * Category View Block class
10
10
* @api
11
- * @package Magento\Catalog\Block\Category
12
11
* @since 100.0.2
13
12
*/
14
13
class View extends \Magento \Framework \View \Element \Template implements \Magento \Framework \DataObject \IdentityInterface
15
14
{
16
15
/**
17
- * Core registry
18
- *
19
16
* @var \Magento\Framework\Registry
20
17
*/
21
18
protected $ _coreRegistry = null ;
22
19
23
20
/**
24
- * Catalog layer
25
- *
26
21
* @var \Magento\Catalog\Model\Layer
27
22
*/
28
23
protected $ _catalogLayer ;
@@ -32,40 +27,56 @@ class View extends \Magento\Framework\View\Element\Template implements \Magento\
32
27
*/
33
28
protected $ _categoryHelper ;
34
29
30
+ /**
31
+ * @var \Magento\Catalog\Helper\Data|null
32
+ */
33
+ private $ catalogData ;
34
+
35
35
/**
36
36
* @param \Magento\Framework\View\Element\Template\Context $context
37
37
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
38
38
* @param \Magento\Framework\Registry $registry
39
39
* @param \Magento\Catalog\Helper\Category $categoryHelper
40
40
* @param array $data
41
+ * @param \Magento\Catalog\Helper\Data|null $catalogData
41
42
*/
42
43
public function __construct (
43
44
\Magento \Framework \View \Element \Template \Context $ context ,
44
45
\Magento \Catalog \Model \Layer \Resolver $ layerResolver ,
45
46
\Magento \Framework \Registry $ registry ,
46
47
\Magento \Catalog \Helper \Category $ categoryHelper ,
47
- array $ data = []
48
+ array $ data = [],
49
+ \Magento \Catalog \Helper \Data $ catalogData = null
48
50
) {
49
51
$ this ->_categoryHelper = $ categoryHelper ;
50
52
$ this ->_catalogLayer = $ layerResolver ->get ();
51
53
$ this ->_coreRegistry = $ registry ;
54
+ $ this ->catalogData = $ catalogData ?? \Magento \Framework \App \ObjectManager::getInstance ()
55
+ ->get (\Magento \Catalog \Helper \Data::class);
52
56
parent ::__construct ($ context , $ data );
53
57
}
54
58
55
59
/**
60
+ * @inheritdoc
56
61
* @return $this
57
62
*/
58
63
protected function _prepareLayout ()
59
64
{
60
65
parent ::_prepareLayout ();
61
66
62
- $ this ->getLayout ()->createBlock (\Magento \Catalog \Block \Breadcrumbs::class);
67
+ $ block = $ this ->getLayout ()->createBlock (\Magento \Catalog \Block \Breadcrumbs::class);
63
68
64
69
$ category = $ this ->getCurrentCategory ();
65
70
if ($ category ) {
66
71
$ title = $ category ->getMetaTitle ();
67
72
if ($ title ) {
68
73
$ 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 )));
69
80
}
70
81
$ description = $ category ->getMetaDescription ();
71
82
if ($ description ) {
@@ -93,6 +104,8 @@ protected function _prepareLayout()
93
104
}
94
105
95
106
/**
107
+ * Return Product list html
108
+ *
96
109
* @return string
97
110
*/
98
111
public function getProductListHtml ()
@@ -114,6 +127,8 @@ public function getCurrentCategory()
114
127
}
115
128
116
129
/**
130
+ * Return CMS block html
131
+ *
117
132
* @return mixed
118
133
*/
119
134
public function getCmsBlockHtml ()
@@ -131,6 +146,7 @@ public function getCmsBlockHtml()
131
146
132
147
/**
133
148
* Check if category display mode is "Products Only"
149
+ *
134
150
* @return bool
135
151
*/
136
152
public function isProductMode ()
@@ -140,6 +156,7 @@ public function isProductMode()
140
156
141
157
/**
142
158
* Check if category display mode is "Static Block and Products"
159
+ *
143
160
* @return bool
144
161
*/
145
162
public function isMixedMode ()
@@ -149,6 +166,7 @@ public function isMixedMode()
149
166
150
167
/**
151
168
* Check if category display mode is "Static Block Only"
169
+ *
152
170
* For anchor category with applied filter Static Block Only mode not allowed
153
171
*
154
172
* @return bool
0 commit comments