/**
* Returns true if the basket element is still valid
*
* @param \Sonata\Component\Basket\BasketInterface $basket
* @param \Sonata\Component\Product\ProductInterface $product
* @param \Sonata\Component\Basket\BasketElementInterface $basketElement
* @return bool|\Sonata\Component\Basket\BasketElementInterface
*/
public function basketAddProduct(BasketInterface $basket, ProductInterface $product, BasketElementInterface $basketElement)
{
if ($basket->hasProduct($product)) {
return false;
}
$basketElementOptions = $product->getOptions();
// add the default product options to the basket element
if (is_array($basketElementOptions) && !empty($basketElementOptions)) {
foreach ($basketElementOptions as $option => $value) {
$basketElement->setOption($option, $value);
}
}
$this->updateComputationPricesFields($basket, $basketElement, $product);
$basket->addBasketElement($basketElement);
return $basketElement;
}