/** * Build a mock product. * * @param string $id The mock product id. * @param string $country The mock product country. * @param string $language The mock product language. * @return GSC_Product The mock product we built. * @author dhermes@google.com **/ function buildMockProduct($id, $country, $language) { $product = new GSC_Product(); $product->setSKU($id); $product->setTargetCountry($country); $product->setContentLanguage($language); $product->setCondition("new"); $title = "Noname XX500-42P Ethernet Switch - 42 Port - 10/100/1000 Base-T"; $product->setTitle($title); $product->setProductLink("http://www.example.com/sku123"); $product->setPrice("25", "usd"); $product->setDescription("42 Port - 10/100/1000 Base-T, very fast."); $gpc = "Electronics > Networking > Hubs & Switches"; $product->setGoogleProductCategory($gpc); $product->setAvailability("in stock"); $shippingService = "Speedy Shipping - Ground"; $product->addShipping("US", "MA", "5.95", "USD", $shippingService); $product->addTax("US", "CA", "8.25", "true"); return $product; }
public function update($editLink = false, $sku = false, $title = false, $description = false, $link = false, $image = false, $price = false, $adult = 'false', $stock = 'in stock') { $product = new GSC_Product(); $type = "application/atom+xml"; try { $product->setContentLanguage('PT-BR'); $product->setTargetCountry('BR'); $product->setSKU($sku); $product->setProductLink($link); $product->setTitle($title); if ($description) { $product->setDescription($description); } $product->setImageLink($image); $product->setBrand(0); $product->setMpn($sku); $product->setPrice($price, "BRL"); $product->setAdult($adult); $product->setAvailability($stock); $product->setCondition("new"); $product->setEditLink($editLink, $type); $this->_client->updateProduct($product); } catch (Exception $e) { $teste = array($sku, $title, $description, $link, $image, $price, $adult, $stock); var_dump($teste); exit; } }