public function delete(ProductSaleElementDeleteEvent $event)
    {
        if (null !== $pse = ProductSaleElementsQuery::create()->findPk($event->getProductSaleElementId())) {
            $product = $pse->getProduct();

            $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME);

            $con->beginTransaction();

            try {
                // If we are deleting the last PSE of the product, don(t delete it, but insteaf
                // transform it into a PSE detached for any attribute combination, so that product
                // prices, weight, stock and attributes will not be lost.
                if ($product->countSaleElements($con) === 1) {
                    $pse
                        ->setIsDefault(true)
                        ->save($con);
                    // Delete the related attribute combination.
                    AttributeCombinationQuery::create()
                        ->filterByProductSaleElementsId($pse->getId())
                        ->delete($con);
                } else {
                    // Delete the PSE
                    $pse->delete($con);
                    // If we deleted the default PSE, make the last created one the default
                    if ($pse->getIsDefault()) {
                        $newDefaultPse = ProductSaleElementsQuery::create()
                            ->filterByProductId($product->getId())
                            ->filterById($pse->getId(), Criteria::NOT_EQUAL)
                            ->orderByCreatedAt(Criteria::DESC)
                            ->findOne($con)
                        ;
                        if (null !== $newDefaultPse) {
                            $newDefaultPse->setIsDefault(true)->save($con);
                        }
                    }
                }

                // Store all the stuff !
                $con->commit();
            } catch (\Exception $ex) {
                $con->rollback();

                throw $ex;
            }
        }
    }