<?php
namespace App\Entity\ECommerce;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
use App\Entity\ECommerce\Traits\DatesInterface;
use App\Entity\ECommerce\Traits\DatesTrait;
/**
* ProductSubGroup
*
* @ORM\Table(name="product_sub_category", indexes={
* @ORM\Index(name="product_sub_group_ids", columns={"id", "remote_id"}),
* })
* @ORM\Entity(repositoryClass="App\Repository\ECommerce\ProductSubCategoryRepository")
* @ORM\Cache(usage="READ_ONLY", region="public")
*/
class ProductSubCategory implements DatesInterface
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private int $id;
/**
* @ORM\Column(name="remote_id", type="integer", nullable=true)
*/
private ?int $remoteId = null;
/**
* @ORM\Column(name="code", type="string", length=2, nullable=true)
*/
private ?string $code;
/**
* @ORM\Column(name="name", type="string", length=100)
*
* @JMS\Groups({"cart_private", "product_sub_category", "view_product"})
*/
private string $name = '';
/**
* @ORM\ManyToOne(targetEntity="ProductCategory", inversedBy="subCategories")
* @ORM\JoinColumn(name="product_category", nullable=true, referencedColumnName="id")
*/
private ?ProductCategory $category = null;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ECommerce\Product", mappedBy="subCategory")
*/
private Collection $products;
/**
* @ORM\OneToMany(targetEntity="ProductGroup", mappedBy="subCategory")
*/
private Collection $productGroups;
use DatesTrait {
DatesTrait::__construct as __D_construct;
}
public function __construct()
{
$this->products = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
/**
* Set remoteId
*
* @param integer $remoteId
*/
public function setRemoteId($remoteId): static
{
$this->remoteId = $remoteId;
return $this;
}
/**
* Get remoteId
*
* @return int
*/
public function getRemoteId()
{
return $this->remoteId;
}
/**
* Set code
*
* @param string $code
*/
public function setCode($code): static
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* Set name
*
* @param string $name
*/
public function setName($name): static
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set category
*
*
*/
public function setCategory(?ProductCategory $category = null): static
{
$this->category = $category;
return $this;
}
/**
* Get category
*
* @return ProductCategory
*/
public function getCategory()
{
return $this->category;
}
/**
* Add product
*
*
*/
public function addProduct(\App\Entity\ECommerce\Product $product): static
{
$this->products[] = $product;
return $this;
}
/**
* Remove product
*/
public function removeProduct(\App\Entity\ECommerce\Product $product): void
{
$this->products->removeElement($product);
}
/**
* Get products
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProducts()
{
return $this->products;
}
}