Skip to content

Commit ce3356e

Browse files
authored
Allow only actual products in Product Teasers (#386)
* Allow only actual products in Product Teasers * Updated product teaser template to use only car products
1 parent 55d37bf commit ce3356e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Controller/ProductController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ public function productTeaserAction(Request $request, Factory $ecommerceFactory)
226226
if ($request->get('type') == 'object') {
227227
AbstractObject::setGetInheritedValues(true);
228228
$product = AbstractProduct::getById($request->get('id'));
229-
229+
if ($product instanceof Car && $product->getObjectType() === Car::OBJECT_TYPE_VIRTUAL_CAR) {
230+
throw new \Exception('Virtual products are not allowed in product teasers.');
231+
}
230232
$paramsBag['product'] = $product;
231233

232234
//track product impression

templates/areas/product-teaser/view.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
editmode: editmode,
1111
controller: 'App\\Controller\\ProductController::productTeaserAction',
1212
title: 'Drag a product here',
13+
className: 'Car',
1314
height : 'auto',
1415
width: '100%'
1516
})

0 commit comments

Comments
 (0)