protected function workupProducts(&$products)
 {
     $currency = $this->getConfig()->getCurrency();
     foreach ($products as &$p) {
         if ($p['min_price'] == $p['max_price']) {
             $p['price_range'] = wa_currency($p['min_price'], $currency);
         } else {
             $p['price_range'] = wa_currency($p['min_price'], $currency) . '...' . wa_currency($p['max_price'], $currency);
         }
         if ($p['badge']) {
             $p['badge'] = shopHelper::getBadgeHtml($p['badge']);
         }
         unset($p['meta_description'], $p['meta_keywords'], $p['meta_title'], $p['description'], $p['summary']);
     }
     unset($p);
     if ($this->sort == 'count') {
         foreach ($products as &$p) {
             $p['icon'] = shopHelper::getStockCountIcon($p['count']);
         }
     } else {
         if ($this->sort == 'create_datetime') {
             foreach ($products as &$p) {
                 $p['create_datetime_str'] = wa_date('humandatetime', $p['create_datetime']);
             }
         } else {
             if ($this->sort == 'rating') {
                 foreach ($products as &$p) {
                     $p['rating_str'] = shopHelper::getRatingHtml($p['rating'], 10, true);
                 }
             } else {
                 if ($this->sort == 'total_sales') {
                     $currency = wa('shop')->getConfig()->getCurrency();
                     foreach ($products as &$p) {
                         $p['total_sales_str'] = wa_currency($p['total_sales'], $currency);
                     }
                 }
             }
         }
     }
     unset($p);
     $info = $this->collection->getInfo();
     if ($info['hash'] == 'category') {
         $product_ids = array_keys($products);
         $category_products_model = new shopCategoryProductsModel();
         $ids = $category_products_model->filterByEnteringInCategories($product_ids, $info['id']);
         $ids = array_flip($ids);
         foreach ($products as $id => &$product) {
             $product['alien'] = $info['type'] == shopCategoryModel::TYPE_STATIC && !isset($ids[$id]);
         }
         unset($product);
     }
 }
 private function delete($hash, $count, $del_list = false)
 {
     $collection = new shopProductsCollection(implode('/', $hash));
     // check rights to prevent infinite ajax-polling
     $types = $this->getModel('type')->getTypes(false);
     if (is_array($types)) {
         if (empty($types)) {
             $this->response['rest_count'] = 0;
             $this->response['count'] = $count;
             return true;
         } else {
             $collection->addWhere('p.type_id IN (' . implode(',', array_keys($types)) . ')');
         }
     }
     if ($count) {
         $product_ids = array_keys($collection->getProducts('*', 0, $count, false));
         $this->deleteProducts($product_ids);
         // DECREASE count.
         // Ignoring this case for dynamic set lead to tricky BUG, result of which in worst case is deleting ALL products
         $info = $collection->getInfo();
         if ($hash[0] == 'set' || $hash[0] == 'category' || $hash[0] == 'type') {
             $model = $this->getModel($hash[0]);
             $model->updateById($hash[1], array('count' => max($info['count'] - $count, 0)));
         }
     }
     $rest_count = $collection->count();
     $this->response['rest_count'] = $rest_count;
     $this->response['count'] = $count;
     if ($rest_count == 0) {
         $this->response['lists'] = $this->getLists();
         if ($del_list) {
             return $this->deleteList($hash);
         }
     }
     return true;
 }