/** * loads the items in the static variable $order_items * and saves the items for future use. * @return Null | DataObjectSet */ protected function loadIncludedProductItems() { return IncludedProduct_OrderItem::get()->filter(array("OrderID" => $this->Order()->ID)); }
function onBeforeDelete() { parent::onBeforeDelete(); $includedProductsOrderItems = IncludedProduct_OrderItem::get()->filter(array("ParentOrderItemID" => $this->ID, "OrderID" => $this->Order()->ID)); if ($includedProductsOrderItems->count()) { foreach ($includedProductsOrderItems as $includedProductsOrderItem) { $includedProductsOrderItem->delete(); $includedProductsOrderItem->destroy(); } } }