Example #1
0
 /**
  * Find product type for product data (as array)
  * @param   array
  * @param   array
  * @return  ProductType|null
  */
 public static function findByProductData(array $row, array $arrOptions = array())
 {
     if ($row['pid'] > 0 && ($objProduct = Product::findByPk($row['pid'])) !== null) {
         return $objProduct->getRelated('type');
     }
     return static::findByPk($row['type']);
 }
Example #2
0
 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new Product();
         $model->model_uset_id = $this->user->user_id;
         if ($model->findByPk($id)) {
             $model->delete($id);
         } else {
             $errors = TRUE;
         }
         if ($model->getErrors()) {
             $errors = TRUE;
         }
         unset($model);
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         if ($errors) {
             Message::echoJsonError(__('product_no_deleted'));
         } else {
             $countE = AF::get($_POST, 'countE', 100000);
             if (count($modelsID) >= $countE) {
                 $link = AF::link(array('products' => 'view'));
                 Message::echoJsonRedirect($link);
             } else {
                 Message::echoJsonSuccess(__('product_deleted'));
             }
         }
     }
     $this->redirect();
 }