public function execute() { $customer_id = waRequest::request('customer_id', 0, 'int'); $category_id = waRequest::request('category_id', 0, 'int'); if (!$customer_id || !$category_id) { return; } $ccm = new waContactCategoriesModel(); $ccm->add($customer_id, $category_id); $cm = new shopCustomerModel(); $this->response['count'] = $cm->getCategoryCounts($category_id); }
public function execute() { // Category counts // !!! Probably not the best idea to fetch category counts on the fly... $cm = new shopCustomerModel(); $counts = $cm->getCategoryCounts(); // Categories $ccm = new waContactCategoryModel(); $categories = array(); foreach ($ccm->getAll() as $c) { if ($c['app_id'] == 'shop') { $c['cnt'] = ifset($counts[$c['id']], 0); $categories[$c['id']] = $c; } } $this->view->assign('all_customers_count', $cm->countAll()); $this->view->assign('contacts_url', wa()->getAppUrl('contacts')); $this->view->assign('categories', $categories); }