2017 © Pedro Peláez
 

library productdata-php-sdk

affilinet Product Data PHP SDK

image

affilinet/productdata-php-sdk

affilinet Product Data PHP SDK

  • Thursday, August 10, 2017
  • by affilinet
  • Repository
  • 6 Watchers
  • 1 Stars
  • 1,098 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 4 Versions
  • 10 % Grown

The README.md

affilinet Product Data PHP SDK

Grab our Product Data PHP SDK and have access to millions of products within minutes., (*1)

Refer to our documentation in order to get started: https://affilinet.github.io/productdata-php-sdk, (*2)

SensioLabsInsight, (*3)

Installation

This SDK can be installed with composer, (*4)

composer require affilinet/productdata-php-sdk

Please note: This packages requires PHP 5.6 or greater., (*5)

Examples

$config = [
    'publisher_id' => {PUBLISHER ID},
    'product_webservice_password' => {PRODUCT WEBSERVICE PASSWORD}
]

$affilinet = new \Affilinet\ProductData\AffilinetClient($config);

// simple search for t-shirts (using the product webservice)
try {
    $search = new \Affilinet\ProductData\Requests\ProductsRequest($affilinet);
    $query = new \Affilinet\ProductData\Requests\Helper\Query();

    $query->where($query->expr()->exactly('T-Shirt'));

    $search
        ->query( $query)
        ->onlyWithImage()
        ->minPrice(1)
        ->maxPrice(100)
        ->page(1)
        ->pageSize(20);

    $response = $search->send();
}
catch (\Affilinet\ProductData\Exceptions\AffilinetProductWebserviceException $e) {
    // There is an error within your $search
    echo 'Error: ' . $e->getMessage();
}

echo 'Total results : ' . $response->totalRecords() ;

foreach ($response->getProducts() as $product) {
    echo $product->getProductName();
    echo $product->getPriceInformation()->getDisplayPrice();
}

Tests

All tests rely on composer. Please composer install before running the tests. phpunit tests include some integration tests. To run these tests you need to provide an publisherId and productWebservicePassword. Copy Tests/AffilinetTestCredentials.php.dist to Tests/AffilinetTestCredentials.php and enter your PUBLISHER_ID and PRODUCT_WEBSERVICE_PASSWORD, (*6)

To run only the unit tests use this command:, (*7)

phpunit --exclude-group integration

License

Please see the license file for more information., (*8)

The Versions