Skip to content

Latest commit

 

History

History
67 lines (53 loc) · 2.26 KB

ProductModel.md

File metadata and controls

67 lines (53 loc) · 2.26 KB

Represents a Product

Before checking this model out, it is recommended to take a look at the following:

List of methods

Field in API Setter in php-client-v2 Getter in php-client-v2 Comments
sku setSku(string $sku) getSku()
name setName(string $name) getName()
base_name setBaseName(string $base_name) getBaseName() Additional name for campaigns purpose
brand setBrand(string $brand) getBrand()
description setDescription(string $description) getDescription()
url setUrl(string $url) getUrl()
image_url setImageUrl(string $image_url) getImageUrl()
price setPrice(float $price) getPrice()
offer_price setOfferPrice(float $offer_price) getOfferPrice() Special-offer price
stock setStock(int $stock) getStock()
available setAvailable(boolean $available) getAvailable()
category setCategory(array $category)
addCategory(\WoowUpV2\Models\CategoryModel $category)
getCategory()
specifications setSpecifications(array $specifications) getSpecifications()
metadata setMetadata($metadata) getMetadata()
id not available getId() WoowUp's product-id
createtime not available getCreatetime()
updatetime not available getUpdatetime()

Validation

To have a valid Product the following fields must be defined:

  • sku
  • name

Example

<?php

include '\WoowUpV2\Models\ProductModel';
include '\WoowUpV2\Models\CategoryModel';

// Creating empty product
$product = new \WoowUpV2\Models\ProductModel();

// Setting SKU and name
$product->setSku('JCK-001-234');
$product->setName('Winter Jacket 001');

// Validation should return true
var_dump($product->validate());

// Creating a category and a subcategory Jackets -> Winter
$category = new \WoowUpV2\Models\CategoryModel();
$category->setId('JCK');
$category->setName('Jackets');

$subcategory = new \WoowUpV2\Models\CategoryModel();
$subcategory->setId('WNT');
$subcategory->setName('Winter');


// Adding category
// Option 1
$product->addCategory($category);
$product->addCategory($subcategory);
// Option 2
$product->setCategory(array($category, $subcategory));