* If you did use by now the content API for shopping, * migrating should be quite easy, most of the services follow a similar pattern * * As a first step you need to authorize for the ProductsUp API. * Your client id and secret are provided at http://platform.productsup.com/ * * With them you can create a new client object: * */ $client = new Productsup\Client(); $client->id = 1234; $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 */
* alternatively you could reference the site by its id in the tag object you insert */ // $tag->site_id = $site->id; $tag = $tagService->insert($tag); echo 'your new inserted tag:' . PHP_EOL; print_r($tag); /** * once you added a tag, sites may get also referenced by it, * you can now use a tag object as alternative for the id: * * note: keys and values are only allowed to contain a-z and 0-9 as characters */ $tag = new \Productsup\Platform\Tag(); $tag->key = 'myidentifier'; $tag->value = '321'; $sitesService = new \Productsup\Service\Sites($Client); $sites = $sitesService->get($tag); echo 'result for getting a site via its tag:' . PHP_EOL; print_r($sites); /** * if you do have a site_id and want to know which tags are assigned to it, you can query for them like this: */ $tagService = new \Productsup\Service\Tags($Client); $tagService->setSite($sites[0]); $tags = $tagService->get(); echo 'tags assigned to the test-site:' . PHP_EOL; print_r($tags); /** * if you want to change an existing tag, you can simply update it: */ $tagService = new \Productsup\Service\Tags($Client);
$Project->id = 9659; $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