$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)); $productsService->delete(array('id' => 1)); $productsService->commit();
/** * Adding one product to insert. * * A product is represented by an array. * There is no fixed structure you have to follow, * the keys you use will become the column name for the resulting upload * * note: you have to call commit() at the end before the data actually gets handled */ $ProductService->insert(array('id' => 123, 'price' => 39.9, 'description' => 'some text')); $ProductService->insert(array('id' => 124, 'price' => 99.98999999999999, 'description_de' => 'ein text')); // adding 5000 random "products" for ($i = 0; $i < 5000; $i++) { $ProductService->insert(array('id' => uniqid(), 'test' => md5(uniqid()), 'created' => microtime(true), 'price' => mt_rand(0, 1000000) / 100)); } /** * deleting products works the same as inserting products: */ $ProductService->delete(array('id' => 123)); /** * if you added all products, call commit to start the processing: * * note: you may not insert or delete products after the submit. * if you have more products to insert, please create a new service */ $result = $ProductService->commit(); var_dump($result); /** * if you encounter any problems after you started the upload, you can tell the api to discard all uploaded data: */ //$result = $ProductService->discard();