<?php
namespace App\Entity\ECommerce;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\ECommerce\Traits\DatesInterface;
use App\Entity\ECommerce\Traits\DatesTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
/**
* Category
*
* @ORM\Table(name="product_category", indexes={
* @ORM\Index(name="product_category_ids", columns={"id", "remote_id"}),
* })
*
* @ORM\Entity(repositoryClass="App\Repository\ECommerce\ProductCategoryRepository")
* @ORM\Cache(usage="READ_ONLY", region="public")
*/
class ProductCategory implements DatesInterface, TranslatableInterface, \Stringable
{
use TranslatableTrait;
use DatesTrait {
DatesTrait::__construct as __D_construct;
}
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var int
*
* @ORM\Column(name="remote_id", type="integer", nullable=true)
*/
private $remote_id;
/**
* @var ArrayCollection
*
* @ORM\OneToMany(targetEntity="App\Entity\ECommerce\Product", mappedBy="category")
*/
private $products;
/**
* @var ArrayCollection
*
* @ORM\OneToMany(targetEntity="App\Entity\ECommerce\ProductSubCategory", mappedBy="category")
*/
private $subCategories;
/**
* Category constructor.
*/
public function __construct()
{
$this->__D_construct();
$this->products = new ArrayCollection();
}
public function __toString(): string
{
return (string) $this->translate()->getName();
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Add product
*
*
*/
public function addProduct(Product $product): ProductCategory
{
$this->products[] = $product;
return $this;
}
/**
* Remove product
*/
public function removeProduct(Product $product): void
{
$this->products->removeElement($product);
}
/**
* Get products
*/
public function getProducts(): Collection
{
return $this->products;
}
/**
* Set remoteId
*
* @param integer $remoteId
*/
public function setRemoteId($remoteId): static
{
$this->remote_id = $remoteId;
return $this;
}
/**
* Get remoteId
*
* @return integer
*/
public function getRemoteId()
{
return $this->remote_id;
}
/**
* Add subCategory
*
*
*/
public function addSubCategory(\App\Entity\ECommerce\ProductSubCategory $subCategory): static
{
$this->subCategories[] = $subCategory;
return $this;
}
/**
* Remove subCategory
*/
public function removeSubCategory(\App\Entity\ECommerce\ProductSubCategory $subCategory): void
{
$this->subCategories->removeElement($subCategory);
}
/**
* Get subCategories
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getSubCategories()
{
return $this->subCategories;
}
}