17
17
18
18
namespace Meta \Conversion \Block \Pixel ;
19
19
20
+ use Magento \Catalog \Model \Layer as CatalogLayer ;
21
+ use Magento \Catalog \Model \Layer \Resolver as CatalogLayerResolver ;
22
+ use Magento \Checkout \Model \Session as CheckoutSession ;
23
+ use Magento \Framework \Escaper ;
24
+ use Magento \Framework \View \Element \Template \Context ;
25
+ use Meta \BusinessExtension \Helper \FBEHelper ;
26
+ use Meta \BusinessExtension \Model \System \Config as SystemConfig ;
27
+ use Meta \Conversion \Helper \MagentoDataHelper ;
28
+
20
29
/**
21
30
* @api
22
31
*/
23
32
class ViewCategory extends Common
24
33
{
34
+ /**
35
+ * @var CatalogLayer
36
+ */
37
+ private CatalogLayer $ catalogLayer ;
38
+
39
+ /**
40
+ * Head constructor
41
+ *
42
+ * @param Context $context
43
+ * @param FBEHelper $fbeHelper
44
+ * @param MagentoDataHelper $magentoDataHelper
45
+ * @param SystemConfig $systemConfig
46
+ * @param Escaper $escaper
47
+ * @param CheckoutSession $checkoutSession
48
+ * @param CatalogLayerResolver $catalogLayerResolver
49
+ * @param array $data
50
+ */
51
+ public function __construct (
52
+ Context $ context ,
53
+ FBEHelper $ fbeHelper ,
54
+ MagentoDataHelper $ magentoDataHelper ,
55
+ SystemConfig $ systemConfig ,
56
+ Escaper $ escaper ,
57
+ CheckoutSession $ checkoutSession ,
58
+ CatalogLayerResolver $ catalogLayerResolver ,
59
+ array $ data = []
60
+ ) {
61
+ parent ::__construct (
62
+ $ context ,
63
+ $ fbeHelper ,
64
+ $ magentoDataHelper ,
65
+ $ systemConfig ,
66
+ $ escaper ,
67
+ $ checkoutSession ,
68
+ $ data
69
+ );
70
+ $ this ->catalogLayer = $ catalogLayerResolver ->get ();
71
+ }
72
+
25
73
/**
26
74
* Get Category name
27
75
*
28
76
* @return string|null
29
77
*/
30
78
public function getCategoryName ()
31
79
{
32
- return $ this ->getLayout ()-> getBlock ( ' category.description ' ) ->getCurrentCategory ()->getName ();
80
+ return $ this ->catalogLayer ->getCurrentCategory ()->getName ();
33
81
}
34
82
35
83
/**
@@ -49,6 +97,6 @@ public function getEventToObserveName()
49
97
*/
50
98
public function getCategoryId ()
51
99
{
52
- return $ this ->getLayout ()-> getBlock ( ' category.description ' ) ->getCurrentCategory ()->getId ();
100
+ return $ this ->catalogLayer ->getCurrentCategory ()->getId ();
53
101
}
54
102
}
0 commit comments