Skip to content

Commit

Permalink
Non-visible child products in bundle cause Fatal Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
jissereitsma committed Jun 20, 2023
1 parent fad2369 commit 025412f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.4.1] - 20 June 2023
### Fixed
- Non-visible child products in bundle cause Fatal Exception

## [3.4.0] - 19 June 2023
### Added
- Option to delay loading GTM until user interaction is triggered
Expand Down
11 changes: 8 additions & 3 deletions DataLayer/Mapper/CartItemDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@ public function __construct(
/**
* @param CartItemInterface $cartItem
* @return array
* @throws NoSuchEntityException
* @throws LocalizedException
*/
public function mapByCartItem(CartItemInterface $cartItem): array
{
$product = $this->productRepository->get($cartItem->getSku());
$cartItemData = $this->productDataMapper->mapByProduct($product);
try {
$product = $this->productRepository->get($cartItem->getSku());
$cartItemData = $this->productDataMapper->mapByProduct($product);
} catch (NoSuchEntityException $e) {
$cartItemData = [];
}

return array_merge($cartItemData, [
'item_sku' => $cartItem->getSku(),
'item_name' => $cartItem->getName(),
'order_item_id' => $cartItem->getItemId(),
'quantity' => (float) $cartItem->getQty(),
Expand Down
1 change: 0 additions & 1 deletion DataLayer/Tag/Cart/CartItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function get(): array

$cartItemsData = [];
foreach ($cartItems as $cartItem) {
$cartItem->getProduct();
$cartItemData = $this->cartItemDataMapper->mapByCartItem($cartItem);
$cartItemsData[] = $cartItemData;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yireo/magento2-googletagmanager2",
"version": "3.4.0",
"version": "3.4.1",
"license": "OSL-3.0",
"type": "magento2-module",
"homepage": "https://www.yireo.com/software/magento-extensions/googletagmanager2",
Expand Down

0 comments on commit 025412f

Please sign in to comment.