Skip to content

Commit 807b3cf

Browse files
authored
Fix for category (#238)
* fix for category * added missing @param
1 parent d45c838 commit 807b3cf

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

app/code/Meta/Conversion/Block/Pixel/ViewCategory.php

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,67 @@
1717

1818
namespace Meta\Conversion\Block\Pixel;
1919

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+
2029
/**
2130
* @api
2231
*/
2332
class ViewCategory extends Common
2433
{
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+
2573
/**
2674
* Get Category name
2775
*
2876
* @return string|null
2977
*/
3078
public function getCategoryName()
3179
{
32-
return $this->getLayout()->getBlock('category.description')->getCurrentCategory()->getName();
80+
return $this->catalogLayer->getCurrentCategory()->getName();
3381
}
3482

3583
/**
@@ -49,6 +97,6 @@ public function getEventToObserveName()
4997
*/
5098
public function getCategoryId()
5199
{
52-
return $this->getLayout()->getBlock('category.description')->getCurrentCategory()->getId();
100+
return $this->catalogLayer->getCurrentCategory()->getId();
53101
}
54102
}

0 commit comments

Comments
 (0)