/**
  * Convert a product array into a product object.
  *
  * @param array $aProduct product.
  *
  * @return Product converted product.
  */
 private static function convertToObject($aProduct)
 {
     $oProduct = new Product();
     $oProduct->setId(intval($aProduct['id']));
     $oProduct->setName($aProduct['name']);
     $oProduct->setDescription($aProduct['description']);
     $oProduct->setImage($aProduct['image']);
     $oProduct->setPrice(floatval($aProduct['price']));
     $oProduct->setRating(intval($aProduct['rating']));
     $oProduct->setActive(intval($aProduct['active']));
     $aCategories = CategoryManager::getFromProductId($oProduct->getId());
     foreach ($aCategories as $oCategory) {
         $oProduct->addCategory($oCategory);
     }
     return $oProduct;
 }
 private function showAction()
 {
     // no id => redirect home
     if (!array_key_exists('id', $_GET)) {
         $this->homeAction();
         return;
     }
     $iId = intval($_GET['id']);
     $oProduct = ProductManager::get($iId);
     // product not found => redirect home
     if (null === $oProduct) {
         $this->homeAction();
         return;
     } else {
         $aCategories = CategoryManager::getFromProductId($iId);
         $aComments = CommentManager::getAllFromProduct($oProduct);
         $aSimilarProducts = ProductManager::getRandom(4, 1);
         require ROOT . 'src/ecommerce/view/product/show.php';
     }
 }