예제 #1
0
 /**
  * @throws \Exception
  */
 public function index()
 {
     $products = null;
     try {
         // Get the category Id for 'Accommodation'
         $accommodationCatId = Atlas::getCategoryId('Accommodation');
         // Get the products specifically for 'Blue Mountains' region belonging to category 'Accommodation'
         $products = Atlas::getProducts(['cats' => $accommodationCatId, 'rg' => 'Blue Mountains']);
     } catch (\Exception $ex) {
         echo json_encode(['error' => $ex->getMessage(), 'error-code' => $ex->getCode()]);
         return;
     }
     // Load the view to display the list of accommodations
     echo self::loadView('Accommodation/list', ['products' => $products]);
 }
예제 #2
0
<?php

use Src\Helpers\Config;
use Src\Model\Atlas;
require_once __DIR__ . '/../../vendor/autoload.php';
// Check if the configuration value can be loaded
echo Config::getInstance()->get('atlas.api', 'key') . "\n\n";
// Check if category ID can be fetched from the Atlas API
echo Atlas::getCategoryId('Accommodation') . "\n\n";
// Check if products with params can be fetched from the Atlas API
$products = Atlas::getProducts(['cats' => 'ACCOMM', 'rg' => 'Blue Mountains']);
$product = Atlas::getProduct('9053120$53072421-f579-4ebe-822f-086c91455403');
print_r($product);