Skip to content

Commit 25a0051

Browse files
committed
MAGE-791 Load current category via new custom registry
1 parent 917d1d9 commit 25a0051

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Block/Algolia.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Algolia\AlgoliaSearch\Helper\Entity\ProductHelper;
1111
use Algolia\AlgoliaSearch\Helper\Entity\SuggestionHelper;
1212
use Algolia\AlgoliaSearch\Helper\LandingPageHelper;
13+
use Algolia\AlgoliaSearch\Registry\CurrentCategory;
1314
use Magento\Catalog\Model\Product;
1415
use Magento\Checkout\Model\Session as CheckoutSession;
1516
use Magento\Customer\Model\Context as CustomerContext;
@@ -97,6 +98,9 @@ class Algolia extends Template implements CollectionDataSourceInterface
9798
*/
9899
protected $date;
99100

101+
/** @var CurrentCategory */
102+
protected CurrentCategory $currentCategory;
103+
100104
protected $priceKey;
101105

102106
/**
@@ -139,6 +143,7 @@ public function __construct(
139143
PersonalizationHelper $personalizationHelper,
140144
CheckoutSession $checkoutSession,
141145
DateTime $date,
146+
CurrentCategory $currentCategory,
142147
array $data = []
143148
) {
144149
$this->config = $config;
@@ -158,6 +163,7 @@ public function __construct(
158163
$this->personalizationHelper = $personalizationHelper;
159164
$this->checkoutSession = $checkoutSession;
160165
$this->date = $date;
166+
$this->currentCategory = $currentCategory;
161167

162168
parent::__construct($context, $data);
163169
}
@@ -255,7 +261,7 @@ public function getStoreId()
255261

256262
public function getCurrentCategory()
257263
{
258-
return $this->registry->registry('current_category');
264+
return $this->currentCategory->get();
259265
}
260266

261267
/** @return Product */

0 commit comments

Comments
 (0)