public function deleteAction(Request $request, Advert $advert)
    {
        $form = $this->createDeleteForm($advert);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            
            $em = $this->getDoctrine()->getManager();
            //remove product purchase, transaction and invoice
            $purchases = $em->getRepository('EcommerceBundle:ProductPurchase')->findByAdvert($advert);
            foreach ($purchases as $purchase) {
                $em->remove($purchase);
            }
            $em->remove($advert);
            $em->flush();
            
            $this->get('session')->getFlashBag()->add('info', 'advert.deleted');
        }

        return $this->redirectToRoute('ecommerce_advert_index');
    }