<?php include __DIR__ . '/../../vendor/autoload.php'; /** * This example shows how to insert or delete products to the ProductsUp API if you used the content API for shopping * before and have already a site to upload to. * * You need to have a site to upload products to. On how to create and enable sites * @see /examples/migrateContentAPI/addingSites.php and @see /examples/Service/Sites.php */ // authorization provided at http://platform.productsup.com/ $client = new \Productsup\Client(); $client->id = 1234; $client->secret = 'simsalabim'; $productsService = new \Productsup\Service\ProductData($client); // reference to the site you want to add or delete products for, for a more detailed description @see /examples/Service/Sites.php $reference = new \Productsup\Platform\Site\Reference(); $reference->setKey('MyTestReference'); $reference->setValue('TestId'); $productsService->setReference($reference); /** * one example with all fields supported by the content API for shopping. Not all of the fields are required, * only the "id" column is mandatory. * * note: the field names are similar to the content API, but may be slightly different */ $product = array('id' => 1, 'additionalImageLink' => 'http://example.com/img/1.jpg,http://example.com/img/2.jpg', 'adult' => 1, 'adwords_grouping' => '', 'adwords_labels' => '', 'adwords_redirect' => '', 'age_group' => 'adult', 'availability' => 'in stock', 'availability_date' => '2014-12-01', 'brand' => 'my brand', 'color' => 'red', 'condition' => 'new', 'custom_label_0' => 'custom label 0', 'custom_label_1' => 'custom label 1', 'custom_label_2' => 'custom label 2', 'custom_label_3' => 'custom label 3', 'custom_label_4' => 'custom label 4', 'description' => 'describes my product', 'energy_efficiency_class' => '', 'expiration_date' => '', 'gender' => 'male', 'google_product_category' => '', 'gtin' => '', 'identifier_exists' => '', 'image_link' => 'http://example.com/img/default.jpg', 'is_bundle' => '', 'item_group_id' => '', 'link' => 'http://example.com/product.html', 'material' => '', 'mobile_link' => 'http://m.example.com/product.html', 'mpn' => '', 'multipack' => '', 'online_only' => '', 'pattern' => '', 'price' => '90.90 EUR', 'product_type' => '', 'sale_price' => '12.34 EUR', 'sale_price_effective_date' => '', 'shipping' => 'DE::DHL:5.00 EUR,AT::Express:19.50', 'shipping_label' => '', 'size_system' => '', 'size_type' => '', 'size' => '', 'title' => 'example product'); try { $productsService->insert($product); $productsService->commit(); } catch (\Productsup\Exceptions\ServerException $e) {
$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)); $productsService->delete(array('id' => 1)); $productsService->commit();
<?php include __DIR__ . '/../../vendor/autoload.php'; /** * Authentication * * You'll get the client id and secret at the plaform (API Access) **/ $Client = new Productsup\Client(); $Client->id = 1234; $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