Je veux utiliser ces classes pour mettre en place une navigation depuis la liste des catégories, vers les produits de la catégorie sélectionnée, Je n'arrive pas à appeler les méthodes pour accéder aux données déja entrées avec les deux dernieres fonctions. comment mettre en place navigation??
Merci d'avance
<?php
class Category
{
public $id, $name;
public function __construct($id,$name){
$this->id = $id;
$this->name = $name;
}
public function setId($id){
$this->id = $id;
}
public function getId($id){
return $this->id;
}
public function setName($name){
$this->name = $name;
}
public function getName($name){
return $this->name;
}
}
class Product
{
public $id, $name, $image, $price,$categories;
public function __construct($id,$name,$image,$price,$categories){
$this->id = $id;
$this->name = $name;
$this->image = $image;
$this->price = $price;
$this->categories = $categories;
}
public function setId($id){
$this->id = $id;
}
public function getId($id){
return $this->id;
}
public function setName($name){
$this->name = $name;
}
public function getName($name){
return $this->name;
}
public function setImage($image){
$this->image = $image;
}
public function getImage($image){
return $this->image;
}
}
function populateCategories(){
$categories = array();
$categories[] = new Category('1','robes');
$categories[] = new Category('2','tops');
$categories[] = new Category('4','pantalons');
return $categories;
}
function populateProducts(){
$categories = array();
$categories[] = new Product('1','Robe en crochet et guipure', 'http://www.nafnaf.com/fr/media/catalog/product/image/680x1000/ONR34-1_1.jpg', '49.9','1');
$categories[] = new Product('2','Robe rayures en maille lurex', 'http://www.nafnaf.com/fr/media/catalog/product/image/680x1000/ONR100-1.jpg','59.90','1');
$categories[] = new Product('3','Robe romantique liberty et noeud' , 'http://www.nafnaf.com/fr/media/catalog/product/image/680x1000/ONR104-1.jpg', '39.90','1');
$categories[] = new Product('4','Top retro plumetis pois','http://www.nafnaf.com/fr/media/catalog/product/image/680x1000/ONC124A-1.jpg', '14.90','2');
$categories[] = new Product('5','Top retro avec lavalliere et manches ballons','http://www.nafnaf.com/fr/media/catalog/product/image/680x1000/ONC106A-1.jpg', '9.90','2');
return $categories;
}
?>