public function delete($oid = null) { if ($attributes = $this->getAttributes($oid)) { DSCTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables'); $table = DSCTable::getInstance('OrderItemAttributes', 'TiendaTable'); foreach ($attributes as $attribute) { if (!$table->delete($attribute->orderitemattribute_id)) { $this->setError($table->getError()); } } } $deleteItem = parent::delete($oid); return parent::check(); }
public function delete($oid = null) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } // is this product in an order? if so, it cannot be deleted DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models'); $model = DSCModel::getInstance('Orderitems', 'TiendaModel'); $model->setState('filter_productid', $this->{$k}); $model->setState('limit', '1'); if ($items = $model->getList()) { $this->setError(JText::sprintf("COM_TIENDA_PRODUCT_CANNOT_DELETE_IN_ORDERS_DISABLED_INSTEAD", $this->{$k})); $this->load($this->{$k}); $this->product_enabled = 0; $this->store(); return parent::check(); } $delete = array(); $delete['attributes'] = $this->deleteItemsWithoutReconciliation('attributes', $this->{$k}); $delete['categories'] = $this->deleteItemsXref('category', $this->{$k}); $delete['comments'] = $this->deleteItemsWithoutReconciliation('comments', $this->{$k}); $delete['compare'] = $this->deleteItems('compare', $this->{$k}); $delete['coupons'] = $this->deleteItemsXref('coupon', $this->{$k}); $delete['files'] = $this->deleteItems('files', $this->{$k}); $delete['issues'] = $this->deleteItems('issues', $this->{$k}); $delete['prices'] = $this->deleteItems('prices', $this->{$k}); $delete['quantities'] = $this->deleteItems('quantities', $this->{$k}); $delete['relations'] = $this->deleteItems('relations', $this->{$k}); $delete['product'] = parent::delete($this->{$k}); $this->deleteResults = $delete; return parent::check(); }