Example #1
0
 * `-- Shirts
 */
$rootCategory = new Category('Collection');
$pantsCategory = new Category('Pants');
$jacketsCategory = new Category('Jackets');
$blousesCategory = new Category('Blouses');
$shirtsCategory = new Category('Shirts');
$rootCategory->addChild($pantsCategory);
$rootCategory->addChild($jacketsCategory);
$rootCategory->addChild($blousesCategory);
$rootCategory->addChild($shirtsCategory);
// Создаем пару брендов
$adidas = new Brand('Adidas');
$nike = new Brand('Nike');
// Создаем продукты...
$pants = new Product('Jogging Pants', 79.95);
$pants->setColor('black');
$pants->setBrand($adidas);
$jeans = new Product('Midi - handcrafted - Jeans', 129.95);
$jeans->setColor('blue');
$jeans->setImage('http://example.com/some-iamge.jpg');
$jeans->setBrand($nike);
$leggings = new Product('Leggings', 99.95);
// ... и добавляем их в категории
$pantsCategory->addProduct($pants);
$pantsCategory->addProduct($jeans);
$pantsCategory->addProduct($leggings);
// Меняем категорию одному из продуктов.
$leggings->setCategory($blousesCategory);
// Подключаем шаблон
include 'view.php';