public function execute() { $type_id = waRequest::post('type_id', null, waRequest::TYPE_ARRAY_INT); $product_model = new shopProductModel(); $count = $product_model->countByField(array('type_id' => $type_id)); $this->response = array('count_text' => $count > 0 ? '≈' . _w('%d product', '%d products', $count) : ''); }
public function execute() { $id = waRequest::get('id', null, waRequest::TYPE_INT); $service_model = new shopServiceModel(); $service = array(); $services = $service_model->getAll('id'); if ($id !== 0) { if (!empty($services)) { if ($id && isset($services[$id])) { $service = $services[$id]; } else { $service = current($services); } } } // blank area for adding new service if (!$service) { $services[] = $this->getEmptyService(); $type_model = new shopTypeModel(); $this->assign(array('services' => $services, 'types' => $type_model->getAll(), 'count' => $service_model->countAll(), 'taxes' => $this->getTaxes())); return; } $service_variants_model = new shopServiceVariantsModel(); $variants = $service_variants_model->get($service['id']); $type_services_model = new shopTypeServicesModel(); $types = $type_services_model->getTypes($service['id']); $products_count = 0; $selected_types = array(); foreach ($types as $type) { if ($type['type_id']) { $selected_types[] = $type['type_id']; } } if (!empty($selected_types)) { $product_model = new shopProductModel(); $products_count = $product_model->countByField(array('type_id' => $selected_types)); } $product_services_model = new shopProductServicesModel(); $this->assign(array('services' => $services, 'service' => $service, 'products' => $product_services_model->getProducts($service['id']), 'types' => $types, 'products_count' => $products_count, 'variants' => $variants, 'count' => $service_model->countAll(), 'taxes' => $this->getTaxes())); }
public function getProductCount($currency) { $product_model = new shopProductModel(); return $product_model->countByField("currency", $currency); }