$Client->secret = 'simsalabim';
$ProductService = new Productsup\Service\ProductData($Client);
/**
 * Optional, define chunk site to submit products in parts using multiple 
 * post requests. Default is 5000
 */
$ProductService->setPostLimit(1000);
$Reference = new Productsup\Platform\Site\Reference();
/**
 * You have to specify the site the products belong to.
 * This is done by references to the site.
 *
 * In case you have a productsup site id, you can pass it like this:
 **/
$Reference->setKey($Reference::REFERENCE_SITE);
$Reference->setValue(397);
// Site ID
/**
 * In case you want to use your own reference:
 **/
//$Reference->setKey('merchant_id'); // A site tag
//$Reference->setValue(1234); // Value of the tag
$ProductService->setReference($Reference);
/**
 * you may specify which type of import you plan to send:
 *
 * a full import replaces all existing products (default, if not specified)
 * a delta import is used to update the latest full import
 *
 * note: one import/service has only one type
 */
$reference = new \Productsup\Platform\Site\Reference();
$reference->setKey('MyTestReference');
$reference->setValue('TestId');
$siteObject->addReference($reference);
$siteObject = $siteService->insert($siteObject);
/**
 * To enable an export to a Google Content API, you can use the "exports service":
 */
$exportService = new \Productsup\Service\Exports($client);
/**
 * adding a reference to the site you want to export:
 * for more information on how references in services work, @see /examples/Service/ProductData.php
 */
$Reference = new \Productsup\Platform\Site\Reference();
$Reference->setKey('MyTestReference');
$Reference->setValue('TestId');
$exportService->setReference($Reference);
/**
 * enableContentApi enables the export to one of your merchant centers
 *
 * note: it is mandatory to authorize the "parent id" via OAuth at http://platform.productsup.com/ before you enable exports
 */
$exportService->enableContentApi('1234', '4321', 'de', 'de');
/**
 * From now on, you can upload products to this site:
 *
 * For more detailed explanation on the product service
 * @see /examples/Service/ProductData.php and @see /examples/migrateContentAPI/addingProducts.php
 */
$productsService = new \Productsup\Service\ProductData($client);
$productsService->insert(array('id' => 1, 'title' => 'my first product', 'description' => 'this is the first product', 'price' => 99.90000000000001));
Пример #3
0
$newProject = $Projects->insert($projectObject);
// create the service and reference the project
$SitesService = new \Productsup\Service\Sites($Client);
$SitesService->setProject($newProject);
$siteObject = new \Productsup\Platform\Site();
$siteObject->title = 'new example site';
/**
 * if you want to reference the project from now on with your identifier,
 * you can create a reference while inserting:
 *
 * note: references have to be unique,
 * if you try to add a reference that already exists you will receive an conflict exception
 */
$reference = new \Productsup\Platform\Site\Reference();
$reference->setKey('MyTestReference');
$reference->setValue(uniqid());
$siteObject->addReference($reference);
// perform the actual insert
$newSite = $SitesService->insert($siteObject);
echo 'new inserted site:' . PHP_EOL;
print_r($newSite);
/**
 * to update the site entry, you can send the edited site object
 */
$newSite->title = 'updated site name';
$updatedSite = $SitesService->update($newSite);
echo 'updated site:' . PHP_EOL;
print_r($updatedSite);
/**
 * you can also delete sites:
 */