Esempio n. 1
0
<?php

use MESH\Commerce;
require '../bootstrap.php';
require '../includes.php';
$async = isset($_GET['async']) ? $_GET['async'] : 1;
$mesh = getSDK($async);
$start = microtime(true);
$products = array();
$skus = array('193965', '121017', '185469', '178114', '185458', '193962', '193961', '185463', '185464', '190977', '192717', '006875', '193965', '121017', '185469', '178114', '185458', '193962', '193961', '185463', '185464', '190977', '192717', '006875');
foreach ($skus as $sku) {
    $product = $mesh->products->createProduct($sku);
    $product->load();
    $products[] = $product;
}
$names = theme('all-names', array('products' => $products));
$time = getTime($start);
echo theme('async', array('async' => $async, 'time' => $time, 'names' => $names));
Esempio n. 2
0
<?php

require '../bootstrap.php';
require '../includes.php';
$mesh = getSDK();
$list = $mesh->products->createProductList();
$list->addFilter('q', 'green');
$list->addFilter('categories', 'footwear');
try {
    $list->load();
} catch (MESH\Commerce\Exceptions\NotFoundException $e) {
    echo 'Not Found: ' . $e->getMessage();
    die;
} catch (MESH\Commerce\Exceptions\MeshException $e) {
    echo 'Error: ' . $e->getMessage();
    die;
}
$products = '';
foreach ($list->getProducts() as $product) {
    $products .= productRow($product);
}
// OR
$products = '';
foreach ($list as $product) {
    $products .= productRow($product);
}
echo theme('product-list', array('count' => $list->getCount(), 'products' => $products));
/**
 * Display functions
 */
function productRow(MESH\Commerce\Products\ListableProduct $product)
Esempio n. 3
0
<?php

require '../bootstrap.php';
require '../includes.php';
$mesh = getSDK(false, true);
$start = microtime(true);
$skus = array('193965', '121017', '185469', '178114', '185458', '193962', '193961', '185463', '185464', '190977', '192717', '006875', '193965', '121017', '185469', '178114', '185458', '193962', '193961', '185463', '185464', '190977', '192717', '006875');
$promises = array();
foreach ($skus as $sku) {
    $promises[] = $mesh->products->createProductAsync($sku);
}
$promise = React\Promise\all($promises)->done(function ($products) use($start) {
    $content = theme('all-names', array('products' => $products));
    $time = getTime($start);
    echo theme('all', array('time' => $time, 'names' => $content));
}, function ($error) use($start) {
    $time = getTime($start);
    echo theme('failture', array('time' => $time, 'error' => $error->getMessage()));
});