function getCategoryItems($categoryName, $lang) { $items = array(); $articleDB = new ArticleDB(); $variantDB = new VariantDB(); $res = $articleDB->getAllArticlesFromCategory($categoryName, $lang); while ($item = $res->fetch_object()) { $itemName = $item->ArticleName; if ($item->TranslatedName != null) { $itemName = $item->TranslatedName; } $itemDescription = $item->ArticleDescription; if ($item->TranslatedName != null) { $itemDescription = $item->TranslatedDescription; } $itemImage = "No_image_available.png"; if ($item->ArticleImage != null) { $itemImage = $item->ArticleImage; } $itemImage = "./img/" . $itemImage; $varRes = $variantDB->getAllVariantsFromArticle($item->Article_ID, $lang); $variants = array(); while ($variant = $varRes->fetch_object()) { $variantName = $variant->VariationName; if ($variant->TranslatedName != null) { $variantName = $variant->TranslatedName; } $variantDescription = $variant->VariationDescription; if ($variant->TranslatedName != null) { $variantDescription = $variant->TranslatedDescription; } $variants[] = new articleVariant($variant->Variation_ID, $variantName, $variant->VariationPrice); } $items[] = new article($item->Article_ID, $itemName, $item->ArticlePrice, $itemDescription, $itemImage, $variants); } return $items; }