diff --git a/Controller/Product/Card.php b/Controller/Product/Card.php index d9954a83..00a4bd60 100644 --- a/Controller/Product/Card.php +++ b/Controller/Product/Card.php @@ -36,10 +36,10 @@ public function __construct( */ public function execute(): HttpInterface { - $productId = $this->request->getParam('product_id'); + $itemId = (string) $this->request->getParam('item_id'); $cardType = $this->request->getParam('card_type'); - $itemHtml = $cardType ? $this->cacheHelper->load((int)$productId, $cardType) : - $this->cacheHelper->load((int)$productId); + $itemHtml = $cardType ? $this->cacheHelper->load($itemId, $cardType) : + $this->cacheHelper->load($itemId); $response = $this->httpFactory->create(); $response->appendBody($itemHtml); diff --git a/Helper/Cache.php b/Helper/Cache.php index 2aeff9e6..ec98b2d5 100644 --- a/Helper/Cache.php +++ b/Helper/Cache.php @@ -47,29 +47,29 @@ public function __construct( } /** - * @param int $productId + * @param string $itemId * @param string $cardType * @return string * @throws LocalizedException * @throws NoSuchEntityException */ - public function load(int $productId, string $cardType = 'default'): string + public function load(string $itemId, string $cardType = 'default'): string { - $result = $this->cache->load($this->getCacheKey($productId, $cardType)); + $result = $this->cache->load($this->getCacheKey($itemId, $cardType)); return $result ? $result : ''; } /** * @param string $data - * @param int $productId + * @param string $itemId * @param string $cardType * @return void * @throws LocalizedException * @throws NoSuchEntityException */ - public function save(string $data, int $productId, string $cardType = 'default'): void + public function save(string $data, string $itemId, string $cardType = 'default'): void { - $this->cache->save($data, $this->getCacheKey($productId, $cardType)); + $this->cache->save($data, $this->getCacheKey($itemId, $cardType)); } /** @@ -128,13 +128,13 @@ public function isHyvaTheme(): bool } /** - * @param int $productId + * @param string $itemId * @param string $cardType * @return string * @throws LocalizedException * @throws NoSuchEntityException */ - private function getCacheKey(int $productId, string $cardType): string + private function getCacheKey(string $itemId, string $cardType): string { $storeId = $this->storeManager->getStore()->getId(); $customerGroupId = $this->customerSession->getCustomerGroupId(); @@ -143,7 +143,7 @@ private function getCacheKey(int $productId, string $cardType): string '%s_%s_%s_%s_%s', $storeId, $customerGroupId, - $productId, + $itemId, $cardType, self::REDIS_CACHE_KEY ); diff --git a/ViewModel/LinkedProductListItem.php b/ViewModel/LinkedProductListItem.php index cd76b70d..ae573864 100644 --- a/ViewModel/LinkedProductListItem.php +++ b/ViewModel/LinkedProductListItem.php @@ -48,7 +48,7 @@ public function getItemHtml( ); } - $productId = (int) $product->getId(); + $productId = (string) $product->getId(); $cardType = str_replace(' ', '_', $params['card_type']); if (!$this->cacheHelper->load($productId, $cardType)) { $itemHtml = $this->getItemHtmlWithRenderer( @@ -60,7 +60,7 @@ public function getItemHtml( } return sprintf( - '', + '', Cache::PRODUCT_CARD_PATH, $productId, $cardType diff --git a/ViewModel/ProductListItem.php b/ViewModel/ProductListItem.php index 1e9b160b..2a2d6869 100644 --- a/ViewModel/ProductListItem.php +++ b/ViewModel/ProductListItem.php @@ -63,8 +63,8 @@ public function getItemHtml( ); } - $productId = (int) $item->getId(); - if (!$this->cacheHelper->load($productId)) { + $itemId = (string) $item->getId(); + if (!$this->cacheHelper->load($itemId)) { if ($isVisual) { $itemHtml = $this->getVisualHtml($item); } else { @@ -78,10 +78,10 @@ public function getItemHtml( ); } - $this->cacheHelper->save($itemHtml, $productId); + $this->cacheHelper->save($itemHtml, $itemId); } - return sprintf('', Cache::PRODUCT_CARD_PATH, $productId); + return sprintf('', Cache::PRODUCT_CARD_PATH, $itemId); } /**