1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
<?php
/**
* @author @jenschude <jens.schulze@commercetools.de>
* @created: 04.02.15, 16:35
*/
namespace Commercetools\Core\Model\Product;
use Commercetools\Core\Model\Category\CategoryReferenceCollection;
use Commercetools\Core\Model\Common\Context;
use Commercetools\Core\Model\Common\JsonObject;
use Commercetools\Core\Model\Common\LocalizedString;
use Commercetools\Core\Model\ProductType\ProductTypeReference;
use Commercetools\Core\Model\TaxCategory\TaxCategoryReference;
use Commercetools\Core\Model\State\StateReference;
/**
* @package Commercetools\Core\Model\Product
* @link https://docs.commercetools.com/http-api-projects-products.html#productdraft
* @method LocalizedString getName()
* @method ProductDraft setName(LocalizedString $name = null)
* @method LocalizedString getSlug()
* @method ProductDraft setSlug(LocalizedString $slug = null)
* @method LocalizedString getDescription()
* @method ProductDraft setDescription(LocalizedString $description = null)
* @method ProductTypeReference getProductType()
* @method ProductDraft setProductType(ProductTypeReference $productType = null)
* @method CategoryReferenceCollection getCategories()
* @method ProductDraft setCategories(CategoryReferenceCollection $categories = null)
* @method ProductVariantDraft getMasterVariant()
* @method ProductDraft setMasterVariant(ProductVariantDraft $masterVariant = null)
* @method ProductVariantDraftCollection getVariants()
* @method ProductDraft setVariants(ProductVariantDraftCollection $variants = null)
* @method LocalizedString getMetaTitle()
* @method ProductDraft setMetaTitle(LocalizedString $metaTitle = null)
* @method LocalizedString getMetaDescription()
* @method ProductDraft setMetaDescription(LocalizedString $metaDescription = null)
* @method LocalizedString getMetaKeywords()
* @method ProductDraft setMetaKeywords(LocalizedString $metaKeywords = null)
* @method TaxCategoryReference getTaxCategory()
* @method ProductDraft setTaxCategory(TaxCategoryReference $taxCategory = null)
* @method LocalizedSearchKeywords getSearchKeywords()
* @method ProductDraft setSearchKeywords(LocalizedSearchKeywords $searchKeywords = null)
* @method StateReference getState()
* @method ProductDraft setState(StateReference $state = null)
* @method bool getPublish()
* @method ProductDraft setPublish(bool $publish = null)
* @method string getKey()
* @method ProductDraft setKey(string $key = null)
* @method array getCategoryOrderHints()
* @method ProductDraft setCategoryOrderHints(array $categoryOrderHints = null)
*/
class ProductDraft extends JsonObject
{
public function fieldDefinitions()
{
return [
'name' => [self::TYPE => LocalizedString::class],
'slug' => [self::TYPE => LocalizedString::class],
'description' => [self::TYPE => LocalizedString::class, static::OPTIONAL => true],
'productType' => [self::TYPE => ProductTypeReference::class],
'categories' => [self::TYPE => CategoryReferenceCollection::class, static::OPTIONAL => true],
'masterVariant' => [self::TYPE => ProductVariantDraft::class, static::OPTIONAL => true],
'variants' => [self::TYPE => ProductVariantDraftCollection::class, static::OPTIONAL => true],
'metaTitle' => [self::TYPE => LocalizedString::class, static::OPTIONAL => true],
'metaDescription' => [self::TYPE => LocalizedString::class, static::OPTIONAL => true],
'metaKeywords' => [self::TYPE => LocalizedString::class, static::OPTIONAL => true],
'taxCategory' => [static::TYPE => TaxCategoryReference::class, static::OPTIONAL => true],
'searchKeywords' => [static::TYPE => LocalizedSearchKeywords::class, static::OPTIONAL => true],
'state' => [static::TYPE => StateReference::class, static::OPTIONAL => true],
'publish' => [static::TYPE => 'bool', static::OPTIONAL => true],
'key' => [static::TYPE => 'string', static::OPTIONAL => true],
'categoryOrderHints' => [static::TYPE => 'array', static::OPTIONAL => true]
];
}
/**
* @param ProductTypeReference $productType
* @param LocalizedString $name
* @param LocalizedString $slug
* @param Context|callable $context
* @return ProductDraft
*/
public static function ofTypeNameAndSlug(
ProductTypeReference $productType,
LocalizedString $name,
LocalizedString $slug,
$context = null
) {
return static::of($context)
->setProductType($productType)
->setName($name)
->setSlug($slug);
}
/**
* @param ProductTypeReference $productType
* @param LocalizedString $name
* @param LocalizedString $slug
* @param ProductVariantDraft $masterVariant
* @param TaxCategoryReference $taxCategory
* @param Context|callable $context
* @return ProductDraft
*/
public static function ofTypeNameSlugMasterVariantAndTaxCategory(
ProductTypeReference $productType,
LocalizedString $name,
LocalizedString $slug,
ProductVariantDraft $masterVariant,
TaxCategoryReference $taxCategory,
$context = null
) {
return static::of($context)
->setProductType($productType)
->setName($name)
->setSlug($slug)
->setMasterVariant($masterVariant)
->setTaxCategory($taxCategory);
}
/**
* @param ProductTypeReference $productType
* @param LocalizedString $name
* @param LocalizedString $slug
* @param ProductVariantDraft $masterVariant
* @param TaxCategoryReference $taxCategory
* @param bool $publish
* @param Context|callable $context
* @return ProductDraft
*/
public static function ofTypeNameSlugMasterVariantTaxCategoryAndPublish(
ProductTypeReference $productType,
LocalizedString $name,
LocalizedString $slug,
ProductVariantDraft $masterVariant,
TaxCategoryReference $taxCategory,
$publish,
$context = null
) {
return static::of($context)
->setProductType($productType)
->setName($name)
->setSlug($slug)
->setMasterVariant($masterVariant)
->setTaxCategory($taxCategory)
->setPublish($publish);
}
}