/** * Update an existion Product * @param integer $no * @param array $data * @return object */ public function update($no, array $data) { $handle = $this->getHandle($no); foreach ($data as $field => $value) { $request = ['productHandle' => $handle, 'value' => $value]; switch (strtolower($field)) { case 'cost': $this->client->Product_SetCostPrice($request); break; case 'description': $this->client->Product_SetDescription($request); break; case 'name': $this->client->Product_SetName($request); break; case 'group': unset($request["value"]); $group = new Group($this->client_raw); $groupHandle = $group->getHandle($value); $request["valueHandle"] = $groupHandle; $this->client->Product_SetProductGroup($request); break; case 'price': $this->client->Product_SetSalesPrice($request); break; case 'rrp': $this->client->Product_SetRecommendedPrice($request); break; case 'unit': unset($request["value"]); $unit = new Unit($this->client_raw); $unitHandle = $unit->getHandle($value); $request["valueHandle"] = $unitHandle; $this->client->Product_SetUnit($request); break; } } return $this->getArrayFromHandles($handle); }