Skip to content

Commit

Permalink
check for null Main Taxon
Browse files Browse the repository at this point in the history
  • Loading branch information
Mati Kochen authored and stefandoorn committed Oct 13, 2017
1 parent d46b067 commit fbb39d6
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Resources/views/Cart/product_show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'name': '{{ product.name }}',
'id': {{ product.id }},
'brand': '{{ sylius.channel.name }}',
'category': '{{ product.mainTaxon.name }}',
'category': '{{ product.mainTaxon ? product.mainTaxon.name : '' }}',
'quantity': 1
};
</script>
2 changes: 1 addition & 1 deletion src/Resources/views/ProductImpressions/_product.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ productImpressions.push({
'name': '{{ product.name }}',
'id': {{ product.id }},
'price': {{ product|sylius_resolve_variant|sylius_calculate_price({'channel': sylius.channel}) / 100 }},
'category': '{{ product.mainTaxon.name }}',
'category': '{{ product.mainTaxon ? product.mainTaxon.name : '' }}',
'list': productListType,
'position': {{ loop.index }}
});
2 changes: 1 addition & 1 deletion src/TagManager/AddTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function addTransaction(OrderInterface $order): void
'id' => $item->getProduct()->getId(),
'quantity' => $item->getQuantity(),
'variant' => $item->getVariant()->getName() ?? $item->getVariant()->getCode(),
'category' => $item->getProduct()->getMainTaxon()->getName(),
'category' => $item->getProduct()->getMainTaxon() ? $item->getProduct()->getMainTaxon()->getName() : '',
'price' => $item->getTotal() / 100,
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/TagManager/CheckoutStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private function addProduct(OrderItemInterface $item): void
'id' => $item->getProduct()->getId(),
'quantity' => $item->getQuantity(),
'variant' => $item->getVariant()->getName() ?? $item->getVariant()->getCode(),
'category' => $item->getProduct()->getMainTaxon()->getName(),
'category' => $item->getProduct()->getMainTaxon() ? $item->getProduct()->getMainTaxon()->getName() : '',
'price' => $item->getTotal() / 100,
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/TagManager/ProductDetailImpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private function addProductVariant(ProductVariantInterface $productVariant): voi
'name' => $product->getName(),
'id' => $product->getId(),
'price' => $this->getPrice($productVariant),
'category' => $product->getMainTaxon()->getName(),
'category' => $item->getProduct()->getMainTaxon() ? $item->getProduct()->getMainTaxon()->getName() : '',
'variant' => $productVariant->getCode(),
];
}
Expand Down

0 comments on commit fbb39d6

Please sign in to comment.