Exemplo n.º 1
0
 /**
  * Delete single entity
  *
  * @param \XLite\Model\AEntity $entity Entity to detach
  *
  * @return void
  */
 protected function performDelete(\XLite\Model\AEntity $entity)
 {
     $carts = (array) \XLite\Core\Database::getRepo('XLite\\Model\\Cart')->findAll();
     $items = array();
     foreach ($carts as $cart) {
         foreach ((array) $cart->getItemsByProductId($entity->getProductId()) as $item) {
             $cart->getItems()->removeElement($item);
             $items[] = $item;
         }
     }
     \XLite\Core\Database::getRepo('XLite\\Model\\OrderItem')->deleteInBatch($items);
     \XLite\Core\Database::getRepo('XLite\\Model\\Cart')->updateInBatch($carts);
     parent::performDelete($entity);
 }