/** * Allows you to retrieve the required order information. * SOAP Method: salesOrderInfo * @param int $id * @return ProxyResultBase */ public function Show($id) { try { $result = $this->GetContext()->GetClient()->salesOrderInfo($this->GetContext()->GetSession(), $id); return ProxyResultBase::CreateSuccessResult($result); } catch (\SoapFault $ex) { $errors = array(); return ProxyResultBase::CreateErrorResult($errors, $ex->getMessage()); } }
/** * Allows you to retrieve information about comments of the required order. * SOAP Method: salesOrderInfo * @return ProxyResultBase */ public function Index(IFilter $filter) { try { $result = $this->GetContext()->GetClient()->salesOrderInfo($this->GetContext()->GetSession(), $this->order_id); return ProxyResultBase::CreateSuccessResult($result->status_history); } catch (\SoapFault $ex) { $errors = array(); return ProxyResultBase::CreateErrorResult($errors, $ex->getMessage()); } }
/** * * @param type $id * @return IProxyResult */ public function ConsultarProduto($id) { $result = $this->proxy->Show($id); if ($result->IsSuccess()) { $productResource = new ProductResource(); $productResource->StdClassToObject($result->GetResult()); return ProxyResultBase::CreateSuccessResult($productResource); } return $result; }
/** * Allows you to unassign a category from a specified product. * SOAP Method: catalogCategoryRemoveProduct * @param int $id * @return ProxyResultBase */ public function Destroy($id) { try { $this->ValidateProductId(); $result = $this->GetContext()->GetClient()->catalogCategoryRemoveProduct($this->GetContext()->GetSession(), $id, $this->product_id, 'product'); return ProxyResultBase::CreateSuccessResult($result); } catch (\SoapFault $ex) { $errors = array(); return ProxyResultBase::CreateErrorResult($errors, $ex->getMessage()); } }
/** * Allows you to update existing stock items. * SOAP Method: catalogInventoryStockItemUpdate * @param array $stockItems * @return ProxyResultBase */ public function UpdateStockItems($stockItems) { if (!is_array($stockItems)) { $errors = array(); return ProxyResultBase::CreateErrorResult($errors, "StockItems is not an array."); } $results = array(); foreach ($stockItems as $stockItem) { $result = $this->Update($stockItem->product_id, $stockItem); array_push($results, $result); } return ProxyResultBase::CreateSuccessResult($results); }
/** * Allows you to retrieve information on billing or shipping addresses from the required order. * SOAP Method: salesOrderInfo * @param int $id * @return ProxyResultBase */ public function Show($id) { try { $result = $this->GetContext()->GetClient()->salesOrderInfo($this->GetContext()->GetSession(), $this->order_id); if ($this->address_int === 'billing') { return ProxyResultBase::CreateSuccessResult($result->billing_address); } if ($this->address_int === 'shipping') { return ProxyResultBase::CreateSuccessResult($result->shipping_address); } } catch (\SoapFault $ex) { $errors = array(); return ProxyResultBase::CreateErrorResult($errors, $ex->getMessage()); } }
/** * HTTP Method: GET * @param int $category_id * @return type */ public function IndexByCategoryId($category_id) { $results = array(); $page = 1; do { $resourceUrl = $this->GetContext()->GetApiUrl() . "/products/category_id={$category_id}?page={$page}&limit=100"; try { $this->GetContext()->GetClient()->fetch($resourceUrl); $lastResponse = $this->GetContext()->GetClient()->getLastResponse(); if (isset($lastResponse)) { $produtos = array_values(get_object_vars(json_decode($lastResponse))); $results = array_merge($results, $produtos); $page++; } } catch (\Exception $except) { return ProxyResultBase::CreateErrorResult(array(), $except->getMessage()); } } while (count($produtos) === 100); return ProxyResultBase::CreateSuccessResult($results); }
/** * Allows you to unassign a website from a specified product. * @param int $id * @return ProxyResultBase */ public function Destroy($id) { $result = $this->Index(); if ($result->IsSuccess()) { $websites = array(); foreach ($result->GetResult() as $website) { array_push($websites, $website->website_id); } $product = new \Resources\Products\ProductResource(); $product->website_ids = array_values(array_diff($websites, array($id))); try { $result = $this->GetContext()->GetClient()->catalogProductUpdate($this->GetContext()->GetSession(), $this->product_id, $product->ObjectToArray(), null, 'product'); return ProxyResultBase::CreateSuccessResult($result); } catch (\Exception $ex) { $errors = array(); return ProxyResultBase::CreateErrorResult($errors, $ex->getMessage()); } } else { return $result; } }
/** * * @param StockItemResource[] $stockItems * @return ProxyResultBase */ public function UpdateStockItems($stockItems) { $resourceName = $this->GetResourceName(); $resourceUrl = $this->GetContext()->GetApiUrl() . "/{$resourceName}"; $resource = array(); foreach ($stockItems as $stockItem) { $resource[$stockItem->item_id] = $stockItem->ObjectToArray(); } $resourceData = json_encode($resource); try { $this->GetContext()->GetClient()->fetch($resourceUrl, $resourceData, OAUTH_HTTP_METHOD_PUT, $this->GetContext()->GetHeaders()); $lastResponse = $this->GetContext()->GetClient()->getLastResponse(); return ProxyResultBase::CreateSuccessResult($lastResponse); } catch (\OAuthException $except) { $lastResponse = json_decode($except->lastResponse); $errors = $lastResponse->messages->error; if (!is_array($errors)) { $errors = array($errors); } return ProxyResultBase::CreateErrorResult($errors, $except->getMessage()); } }
/** * Allows you to delete the required product. * SOAP Method: catalogProductDelete * @param int $id * @return ProxyResultBase */ public function Destroy($id) { try { $result = $this->GetContext()->GetClient()->catalogProductDelete($this->GetContext()->GetSession(), $id, 'product'); return ProxyResultBase::CreateSuccessResult($result); } catch (\Exception $ex) { $errors = array(); return ProxyResultBase::CreateErrorResult($errors, $ex->getMessage()); } }
/** * Delete the required customer. * SOAP Method: customerCustomerDelete * @param int $id * @return ProxyResultBase */ public function Destroy($id) { try { $result = $this->GetContext()->GetClient()->customerCustomerDelete($this->GetContext()->GetSession(), $id); return ProxyResultBase::CreateSuccessResult($result); } catch (\SoapFault $ex) { $errors = array(); return ProxyResultBase::CreateErrorResult($errors, $ex->getMessage()); } }
public function UpdateByStoreId($store_id, $id, IResource $resource) { $this->ValidateProductId(); $resourceUrl = $this->GetContext()->GetApiUrl() . "/products/{$this->product_id}/images/{$id}/store/{$store_id}"; $resourceData = json_encode($resource->ObjectToArray()); try { $this->GetContext()->GetClient()->fetch($resourceUrl, $resourceData, OAUTH_HTTP_METHOD_PUT, $this->GetContext()->GetHeaders()); $lastResponse = $this->GetContext()->GetClient()->getLastResponse(); return ProxyResultBase::CreateSuccessResult($lastResponse); } catch (\OAuthException $except) { $lastResponse = json_decode($except->lastResponse); $errors = $lastResponse->messages->error; if (!is_array($errors)) { $errors = array($errors); } return ProxyResultBase::CreateErrorResult($errors, $except->getMessage()); } }
/** * HTTP Method: DELETE * @param int $id * @return ProxyResultBase */ public function Destroy($id) { $resourceName = $this->GetResourceName(); $resourceUri = $this->GetContext()->GetApiUrl() . "/{$resourceName}/{$id}"; try { $this->GetContext()->GetClient()->fetch($resourceUri, OAUTH_HTTP_METHOD_DELETE); $lastResponse = $this->GetContext()->GetClient()->getLastResponse(); $resource = json_decode($lastResponse); return ProxyResultBase::CreateSuccessResult($resource); } catch (\OAuthException $except) { $lastResponse = json_decode($except->lastResponse); $errors = $lastResponse->messages->error; if (!is_array($errors)) { $errors = array($errors); } return ProxyResultBase::CreateErrorResult($errors, $except->getMessage()); } }