/** * @param $products array of products */ private function insertProducts($products) { $order_id = $this->data['order_id']; $res = $this->productModel->getProductInfoIn($this->lang, $this->ids); $data = array(); $total_product_price = 0; foreach ($res as $product) { $data[$product['product_id']] = $product; } foreach ($products as $basket_product) { $product_id = $basket_product['id']; $quantity = $basket_product['quantity']; $total_product_price += $quantity * $data[$product_id]['price']; $row = array('order_id' => $order_id, 'product_id' => $product_id, 'name' => $data[$product_id]['name'], 'model' => $data[$product_id]['model'], 'quantity' => $quantity, 'price' => $data[$product_id]['price'], 'total' => $quantity * $data[$product_id]['price'], 'tax' => $data[$product_id]['tax_rate'], 'reward' => 0); $this->db->table('oc_order_product')->insert($row); } $this->insertOrderTotal($total_product_price); }
public function actionGetProductsInFilter($language, $filter_name) { $data = $this->productManager->getProductsInFilter($language, $filter_name); $response = new JsonResponse($data); $this->sendResponse($response); }