/** * Retrieves all products in a certain category from the database and * displays them. * * @param string $category category of the products */ public static function get_products($category) { $products = Product::findByCategory($category); foreach ($products as $product) { $ingredients = Product::findIngredients($product->id); if ($product->category != 'Juoma') { $product->price = Ingredient::count_total_price($ingredients); } $product->ingredients = $ingredients; } $ingredients = Ingredient::findByCategory($category); View::make('product/list.html', array('products' => $products, 'ingredients' => $ingredients, 'category' => $category)); }
public function getProducts() { $products = Product::findByCategory($this->id); return $products; }