public function testAddProductCategoryAndProduct(Connection $connection) { $productCategory = new ProductCategory(); $productCategory->setName("name")->setDescription("description")->setImage("image")->setUrl("url"); $productCategoryResource = new ProductCategories($connection); $categoryResponse = $productCategoryResource->post($productCategory); $categoryId = $categoryResponse['CategoryID']; $product = new Product(); $product->addCategory($categoryId); $product->setCost("2")->setLongDescription("long description")->setPrice("3")->setProductImage("image")->setProductName("NEWWW")->setProductURL("url")->setShortDescription("short description")->setSku("sku")->setWeight("2"); $productResource = new Products($connection); return $productResource->post($product); }
public function getResponseFromBody($body) { $categoryResponse = null; if (!empty($body['ErrorCode'])) { $categoryResponse = new ErrorResponse(); $categoryResponse->setErrorCode($body['ErrorCode'])->setMessage($body['Message'])->setIsError(true); } else { $categoryResponse = new ProductCategoryResponse(); $productCategory = new ProductCategory(); $productCategory->setDescription($body['Description'])->setImage($body['Image'])->setName($body['Name'])->setUrl($body['URL'])->setId($body['CategoryID']); $categoryResponse->setProductCategory($productCategory); } return $categoryResponse; }