/**
  * Run function when deleting
  * @see Citruscart/admin/tables/CitruscartTable#save()
  */
 function delete($oid = null, $doReconciliation = true)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if ($doReconciliation) {
         $pa = JTable::getInstance('ProductAttributes', 'CitruscartTable');
         if ($oid) {
             $row = JTable::getInstance('ProductAttributeOptions', 'CitruscartTable');
             $row->load($oid);
             $pa->load($row->productattribute_id);
         } else {
             $pa->load($this->productattribute_id);
         }
         $product_id = $pa->product_id;
     }
     if ($return = parent::delete($oid)) {
         DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
         $model = DSCModel::getInstance('ProductAttributeOptionValues', 'CitruscartModel');
         $model->setState('filter_option', $this->{$k});
         if ($items = $model->getList()) {
             $table = $model->getTable();
             foreach ($items as $item) {
                 if (!$table->delete($item->productattributeoptionvalue_id)) {
                     $this->setError($table->getError());
                 }
             }
         }
         if ($doReconciliation) {
             Citruscart::load("CitruscartHelperProduct", 'helpers.product');
             CitruscartHelperProduct::doProductQuantitiesReconciliation($product_id);
         }
     }
     return parent::check();
 }
Exemplo n.º 2
0
 function setquantities()
 {
     $app = JFactory::getApplication();
     $product_id = $app->input->getInt('id');
     $this->set('suffix', 'productquantities');
     $model = $this->getModel($this->get('suffix'));
     $model->setState('filter_productid', $model->getId());
     $model->setState('filter_vendorid', '0');
     $items = $model->getAll();
     $row = JTable::getInstance('Products', 'CitruscartTable');
     $row->load($model->getId());
     //		$productModel = JModelLegacy::getInstance('Products', 'CitruscartModel');
     //$row = $productModel->getItem();
     Citruscart::load("CitruscartHelperProduct", 'helpers.product');
     // $csvs = CitruscartHelperProduct::getProductAttributeCSVs( $row->product_id );
     // $items = CitruscartHelperProduct::reconcileProductAttributeCSVs( $row->product_id, '0', $items, $csvs );
     CitruscartHelperProduct::doProductQuantitiesReconciliation($product_id);
     $state = parent::_setModelState();
     $ns = $this->getNamespace();
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     $view = $this->getView('products', 'html');
     $view->set('_controller', 'products');
     $view->set('_view', 'products');
     $view->set('_action', "index.php?option=com_citruscart&view=products&task=setquantities&id={$model->getId()}&tmpl=component");
     $view->setModel($model, true);
     $view->assign('state', $model->getState());
     $view->assign('row', $row);
     $view->assign('items', $model->getList());
     $view->setLayout('setquantities');
     $view->setTask(true);
     $view->display();
 }