diff --git a/app/code/Meta/Conversion/Model/Tracker/AddToCart.php b/app/code/Meta/Conversion/Model/Tracker/AddToCart.php index e66413e6..7a10a9ae 100644 --- a/app/code/Meta/Conversion/Model/Tracker/AddToCart.php +++ b/app/code/Meta/Conversion/Model/Tracker/AddToCart.php @@ -8,6 +8,7 @@ use Magento\Framework\Exception\NoSuchEntityException; use Meta\Conversion\Api\TrackerInterface; use Meta\Conversion\Helper\MagentoDataHelper; +use Magento\Store\Model\StoreManagerInterface; class AddToCart implements TrackerInterface { @@ -28,19 +29,27 @@ class AddToCart implements TrackerInterface */ private $magentoDataHelper; + /** + * @var StoreManagerInterface + */ + private StoreManagerInterface $storeManager; + /** * @param MagentoDataHelper $magentoDataHelper * @param ProductRepositoryInterface $productRepository * @param Escaper $escaper + * @param StoreManagerInterface $storeManager */ public function __construct( MagentoDataHelper $magentoDataHelper, ProductRepositoryInterface $productRepository, - Escaper $escaper + Escaper $escaper, + StoreManagerInterface $storeManager ) { $this->magentoDataHelper = $magentoDataHelper; $this->productRepository = $productRepository; $this->escaper = $escaper; + $this->storeManager = $storeManager; } /** @@ -50,7 +59,7 @@ public function getPayload(array $params): array { $productId = $params['productId']; try { - $product = $this->productRepository->getById($productId); + $product = $this->productRepository->getById($productId, false, $this->storeManager->getStore()->getId()); $contentId = $this->magentoDataHelper->getContentId($product); return [ 'currency' => $this->magentoDataHelper->getCurrency(),