/** * This function delete item / product * * @return : integer (1/0) * */ function deleteProduct() { // load model attribute /*JLoader::import('attributes', JPATH_SITE.DS.'components'.DS.'com_quick2cart'.DS.'models'); $attrmodel = new quick2cartModelAttributes(); */ $productHelper = new productHelper(); $jinput = JFactory::getApplication()->input; $item_id = $jinput->get('item_id', '', 'INTEGETR'); $res = $productHelper->deleteWholeProduct($item_id); $productHelper = new productHelper(); $productHelper->deleteNotReqProdImages($item_id, ''); if (!empty($res)) { echo 1; } else { echo 0; } jexit(); }
/** * Method to delete a row from the database table by primary key value. * * @param mixed $pk An optional primary key value to delete. If not set the instance property value is used. * * @return boolean True on success. * * @link http://docs.joomla.org/JTable/delete * @since 11.1 * @throws UnexpectedValueException */ public function delete($pk = null) { /*$this->load($pk); //$result = parent::delete($pk); if ($result) { } return $result; */ $path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helpers' . DS . 'product.php'; if (!class_exists('productHelper')) { JLoader::register('productHelper', $path); JLoader::load('productHelper'); } $productHelper = new productHelper(); if (is_array($pk)) { $status = false; foreach ($pk as $pkid) { $oneProdStatus = $productHelper->deleteWholeProduct($pkid); if ($oneProdStatus === true) { // If atleast one prod is deleted successfull and other not still reurn true. $status = true; } } } else { $status = $productHelper->deleteWholeProduct($pk); } return $status; }
/** * Method to delete a row from the database table by primary key value. * * @param array $items An array of primary key value to delete. * * @return int Returns count of success */ public function delete($items) { $db = $this->getDbo(); $app = JFactory::getApplication(); $count = 0; if (is_array($items)) { foreach ($items as $id) { $productHelper = new productHelper(); $res = $productHelper->deleteWholeProduct($id); $productHelper->deleteNotReqProdImages($id, ''); if (!empty($res)) { $count++; } else { $app->enqueueMessage(JText::_('COM_QUICK2CART_MSG_ERROR_DELETE_PRODUCT'), 'error'); return 0; } } } return $count; }