* 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); /** * 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 *
$Client = new Productsup\Client(); $Client->id = 1234; $Client->secret = 'simsalabim'; /** * first we need a project and a site which should be tagged, * for further explanation see the examples in Projects.php and Sites.php */ $project = new \Productsup\Platform\Project(); $project->name = 'test ' . date('Y-m-d H:i:s'); $projectService = new \Productsup\Service\Projects($Client); $project = $projectService->insert($project); $site = new \Productsup\Platform\Site(); $site->domain = 'test_' . date('Ymdhis') . '.tld'; $site->project_id = $project->id; $sitesService = new \Productsup\Service\Sites($Client); $site = $sitesService->insert($site); /** * if you want to tag your site to later reference it by this tag instead of remembering the provided site_id * you can insert it like this * * note: a tag needs a key and a value, the key is the tags name (e.g. "myidentifier") and value it's value (e.g. "321") */ $tag = new \Productsup\Platform\Tag(); $tag->key = 'myidentifier'; $tag->value = '321'; $tagService = new \Productsup\Service\Tags($Client); /** * note: you need to reference the site you want to tag */ $tagService->setSite($site); /**
$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: */ $result = $SitesService->delete($updatedSite); echo 'result of deleting one site:' . PHP_EOL; var_dump($result);