Skip to content

Commit 3f0b246

Browse files
committed
MAGE-1097: add config helper check
1 parent 140b2ce commit 3f0b246

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Plugin/AddToCartRedirectForInsights.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Algolia\AlgoliaSearch\Plugin;
44

5+
use Algolia\AlgoliaSearch\Helper\ConfigHelper;
56
use Magento\Catalog\Api\ProductRepositoryInterface;
67
use Magento\Catalog\Model\Product;
78
use Magento\CatalogInventory\Api\StockRegistryInterface;
@@ -27,6 +28,7 @@ public function __construct(
2728
protected Session $checkoutSession,
2829
protected StockRegistryInterface $stockRegistry,
2930
protected ManagerInterface $eventManager,
31+
protected ConfigHelper $configHelper,
3032
) {}
3133

3234
/**
@@ -41,6 +43,11 @@ public function __construct(
4143
*/
4244
public function beforeAddProduct(Cart $cartModel, int|Product $productInfo, array|int|DataObject $requestInfo = null)
4345
{
46+
// First, check is Insights are enabled
47+
if (!$this->configHelper->isClickConversionAnalyticsEnabled($this->storeManager->getStore()->getId())) {
48+
return;
49+
}
50+
4451
// If the request doesn't have any insights info, no need to handle it
4552
if (!isset($requestInfo['referer']) || !isset($requestInfo['queryID']) || !isset($requestInfo['indexName'])) {
4653
return;

0 commit comments

Comments
 (0)