コード例 #1
0
$client->secret = 'simsalabim';
/**
 * This client needs to be passed to all services you create:
 */
$siteService = new \Productsup\Service\Sites($client);
/**
 * To import products, you need a project (group of sites) and a site for the products.
 *
 * Once you have a ProductsUp account you also got already one project, you can find its id in the platform.
 * If you want to create a new project, please @see /examples/Service/Projects.php
 *
 * To create a new site it id mandatory to reference the project you want to create the site for:
 */
$project = new \Productsup\Platform\Project();
$project->id = 9697;
$siteService->setProject($project);
/**
 * Creating the new site works like this:
 * for more information about the possible actions of sites @see /examples/Service/Sites.php
 */
$siteObject = new \Productsup\Platform\Site();
$siteObject->title = 'new example site';
$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);
コード例 #2
0
$Sites->setProject($Project);
$SiteList = $Sites->get();
echo 'Getting a site list for a certain project' . PHP_EOL;
print_r($SiteList);
/**
 * to insert one project, you need a reference to the project
 * you can also create a new one:
 */
// creating the project
$projectObject = new \Productsup\Platform\Project();
$projectObject->name = 'example project ' . date('Y-m-d H:i:s');
$Projects = new \Productsup\Service\Projects($Client);
$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);