src/Flexy/ShopBundle/Entity/Product/Product.php line 47
<?php
namespace App\Flexy\ShopBundle\Entity\Product;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\ShopBundle\Entity\Brand;
use App\Flexy\ShopBundle\Entity\Order\OrderItem;
use App\Flexy\ShopBundle\Entity\Payment\PaymentMethod;
use App\Flexy\ShopBundle\Entity\Product\CategoryProduct;
use App\Flexy\ShopBundle\Entity\Promotion\Promotion;
use App\Flexy\ShopBundle\Entity\Shipping\Country;
use App\Flexy\ShopBundle\Entity\Shipping\ShippingMethod;
use App\Flexy\ShopBundle\Entity\Store\Store;
use App\Flexy\ShopBundle\Entity\Vendor\Vendor;
use App\Flexy\ShopBundle\Repository\Product\ProductRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Table;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\InheritanceType;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use Gedmo\Translatable\Translatable;
#[ApiResource(
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
)]
#[ApiFilter(SearchFilter::class, properties: ['name' => 'partial','categoriesProduct' => 'partial','productType'=>'exact'])]
#[Table(name: 'product')]
#[ORM\Entity(repositoryClass: ProductRepository::class)]
#[InheritanceType('JOINED')]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
#[Gedmo\Tree(type: 'nested')]
#[UniqueEntity(
fields: ['name'],
message: 'Ce produit avec ce nom est déja existe, utilisez un autre nom pour ce produit.',
)]
#[ORM\Cache(usage:"NONSTRICT_READ_WRITE",region:"append_depend")]
class Product implements Translatable
{
#[Groups(['read', 'readDeep'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[Groups(['read', 'readDeep','write'])]
#[ORM\Column(type: 'string', length: 255)]
#[Gedmo\Translatable]
private ?string $name = null;
/**
*
* @example the pricipale image of the product
*/
#[Groups(['read', 'readDeep'])]
#[ORM\Column(type: 'string', length: 255,nullable:true)]
private string|null $image = "" ;
#[Groups(['read', 'readDeep'])]
#[ORM\Column(type: 'float',nullable:true)]
private ?float $price = 0;
#[Groups(['read', 'readDeep'])]
#[ORM\Column(type: 'text', nullable: true)]
#[Gedmo\Translatable]
private ?string $description = null;
/**
* #requiredForAi
* @example The principale category of the product (Important)
*/
#[ORM\ManyToOne(targetEntity: CategoryProduct::class, inversedBy: 'productsChildrens',cascade:["persist"])]
private ?\App\Flexy\ShopBundle\Entity\Product\CategoryProduct $parentCategory = null;
/**
*
* @example Sub categories if mentionned
*/
#[ORM\ManyToMany(targetEntity: CategoryProduct::class, inversedBy: 'products', cascade: ['persist'])]
private $categoriesProduct;
/**
*
* @example If productType is variable
*/
#[ORM\OneToMany(targetEntity: AttributValue::class, mappedBy: 'product', cascade: ['persist'])]
#[Groups(['read', 'readDeep'])]
private $attributValues;
#[Groups(['read', 'readDeep'])]
#[ORM\Column(type: 'float', nullable: true)]
private ?float $oldPrice = null;
#[Groups(['read', 'readDeep'])]
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $quantity = null;
/**
*
* @example [simple|variable|pack|subscription] default: simple
*/
#[Groups(['read', 'readDeep'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $productType = "simple";
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Gedmo\Translatable]
private ?string $metaTitle = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Gedmo\Translatable]
private ?string $metaDescription = null;
#[ORM\Column(type: 'simple_array', nullable: true)]
private ?array $metaKeywords = [];
#[ORM\OneToMany(targetEntity: ImageProduct::class, mappedBy: 'product', cascade: ['persist'])]
private $images;
/**
*
* @example Can be the name of the product
*/
#[Gedmo\Slug(fields: ['name'],updatable:false)]
#[ORM\Column(type: 'string', length: 255)]
private ?string $slug = null;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\OneToMany(targetEntity: ProductVariant::class, mappedBy: 'product', cascade: ['persist'])]
private $productVariants;
/**
* #ignoredForAi
*
*/
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isPriceReducedPerPercent = null;
#[ORM\Column(type: 'float', nullable: true)]
private ?float $percentReduction = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $skuCode = null;
#[ORM\OneToMany(targetEntity: OrderItem::class, mappedBy: 'product', cascade: ['persist'])]
private $orderItems;
/**
* #ignoredForAi
*
*/
#[ORM\ManyToOne(targetEntity: Promotion::class, inversedBy: 'products')]
private ?\App\Flexy\ShopBundle\Entity\Promotion\Promotion $promotion = null;
/**
* #ignoredForAi
*
*/
#[ORM\ManyToOne(targetEntity: Vendor::class, inversedBy: 'products')]
private ?\App\Flexy\ShopBundle\Entity\Vendor\Vendor $vendor = null;
/**
* #ignoredForAi
*
*/
#[ORM\ManyToOne(targetEntity: Brand::class, inversedBy: 'products', cascade: ['persist'])]
private ?\App\Flexy\ShopBundle\Entity\Brand $brand = null;
#[ORM\Column(type: 'text', nullable: true)]
#[Gedmo\Translatable]
private ?string $shortDescription = null;
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isPublished = true;
#[ORM\OneToMany(targetEntity: Comment::class, mappedBy: 'product')]
private $comments;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $skuCodeShop = null;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $endAt = null;
/**
* #ignoredForAi
*
*/
#[ORM\ManyToOne(targetEntity: Product::class)]
private ?\App\Flexy\ShopBundle\Entity\Product\Product $clonedProduct = null;
/**
*
* @example [amount|percentage|null] can be null
*/
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $typeReduction = null;
/**
*
* @example number related to typeReduction
*/
#[ORM\Column(type: 'float', length: 255, nullable: true)]
private ?float $valueReduction = null;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductSubscription::class, orphanRemoval: true)]
private Collection $productSubscriptions;
#[ORM\Column(nullable: true)]
#[Groups(['read', 'readDeep'])]
private ?float $subscriptionMonthlyPrice = null;
#[ORM\Column(nullable: true)]
#[Groups(['read', 'readDeep'])]
private ?float $subscriptionYearlyPrice = null;
/**
* #ignoredForAi
*
*/
#[ORM\ManyToOne(inversedBy: 'products')]
private ?Store $store = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $deletedAt = null;
/**
* Used locale to override Translation listener`s locale
* this is not a mapped field of entity metadata, just a simple property
*/
#[Gedmo\Locale]
private $locale;
#[ORM\OneToMany(mappedBy: 'parentProduct', targetEntity: ProductPack::class, orphanRemoval: true,cascade:["persist","remove"])]
private Collection $childrenProductsPack;
#[ORM\Column(nullable: true)]
#[Groups(['read', 'readDeep'])]
private ?bool $labelPriceFrom = null;
#[ORM\ManyToMany(targetEntity: ShippingMethod::class, inversedBy: 'products',cascade:["persist"])]
private Collection $includedShippingMethods;
#[ORM\Column(nullable: true)]
private ?array $metaData = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $defaultCurrency = null;
#[ORM\ManyToMany(targetEntity: PaymentMethod::class, inversedBy: 'products')]
private Collection $includedPaymentMethods;
#[ORM\Column(length: 255, nullable: true)]
private ?string $video = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $videoThumbnail = null;
#[ORM\Column(nullable: true)]
private ?float $costPrice = null;
#[ORM\ManyToMany(targetEntity: Country::class, inversedBy: 'shippingProducts')]
private Collection $shipToCountries;
#[ORM\Column(type: 'integer', nullable: true)]
private $position;
public function __construct()
{
$this->categoriesProduct = new ArrayCollection();
$this->attributValues = new ArrayCollection();
$this->createdAt = new \DateTimeImmutable();
$this->images = new ArrayCollection();
$this->productVariants = new ArrayCollection();
$this->orderItems = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->productSubscriptions = new ArrayCollection();
$this->childrenProductsPack = new ArrayCollection();
$this->includedShippingMethods = new ArrayCollection();
$this->includedPaymentMethods = new ArrayCollection();
$this->shipToCountries = new ArrayCollection();
}
public function __toString(): string
{
return (string) $this->name;
}
public function getId(): ?int
{
return $this->id;
}
#[Groups(['read', 'readDeep'])]
public function getCategoriesByName(){
$categories = [];
foreach($this->categoriesProduct as $singleCategory){
$categories[]=$singleCategory->getName();
}
return $categories;
}
#[Groups(['read'])]
public function getParentCategoryByName(){
$name = null;
if($this->parentCategory){
$name = $this->parentCategory->getName();
}
return $name;
}
public function setId($id=null): self
{
$this->id = $id;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
#[Groups(['read', 'readDeep'])]
public function getReduction(): ?float
{
$reduction = 0;
if($this->typeReduction and $this->valueReduction){
if($this->typeReduction == "percent"){
$reduction = ((float)$this->price / 100) * $this->valueReduction;
}else{
$reduction = $this->valueReduction ;
}
}
return $reduction;
}
public function setPrice(float $price): self
{
$this->price = $price;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* Get the value of image
*/
public function getImage()
{
return $this->image;
}
/**
* Set the value of image
*/
public function setImage($image)
{
$this->image = (string)$image;
return $this;
}
/**
* @return Collection|CategoryProduct[]
*/
public function getCategoriesProduct(): Collection
{
return $this->categoriesProduct;
}
public function addCategoryProduct(CategoryProduct $categoryProduct): self
{
if (!$this->categoriesProduct->contains($categoryProduct)) {
$this->categoriesProduct[] = $categoryProduct;
$categoryProduct->addProduct($this);
}
return $this;
}
public function removeCategoryProduct(CategoryProduct $categoryProduct): self
{
if ($this->categoriesProduct->removeElement($categoryProduct)) {
$categoryProduct->removeProduct($this);
}
return $this;
}
/**
* @return Collection|AttributValue[]
*/
public function getAttributValues(): Collection
{
return $this->attributValues;
}
public function addAttributValue(AttributValue $attributValue): self
{
if (!$this->attributValues->contains($attributValue)) {
$this->attributValues[] = $attributValue;
$attributValue->setProduct($this);
}
return $this;
}
public function removeAttributValue(AttributValue $attributValue): self
{
if ($this->attributValues->removeElement($attributValue)) {
// set the owning side to null (unless already changed)
if ($attributValue->getProduct() === $this) {
$attributValue->setProduct(null);
}
}
return $this;
}
public function getOldPrice(): ?float
{
return $this->oldPrice;
}
public function setOldPrice(?float $oldPrice): self
{
$this->oldPrice = $oldPrice;
return $this;
}
public function getQuantity(): ?int
{
return $this->quantity;
}
public function setQuantity(?int $quantity): self
{
$this->quantity = $quantity;
return $this;
}
public function getProductType(): ?string
{
return $this->productType;
}
public function setProductType(?string $productType): self
{
$this->productType = $productType;
return $this;
}
public function getMetaTitle(): ?string
{
return $this->metaTitle;
}
public function setMetaTitle(?string $metaTitle): self
{
$this->metaTitle = $metaTitle;
return $this;
}
public function getMetaDescription(): ?string
{
return $this->metaDescription;
}
public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;
return $this;
}
public function getMetaKeywords(): ?array
{
return $this->metaKeywords;
}
public function setMetaKeywords(?array $metaKeywords): self
{
$this->metaKeywords = $metaKeywords;
return $this;
}
/**
* @return Collection|ImageProduct[]
*/
public function getImages(): Collection
{
return $this->images;
}
public function addImage(ImageProduct $image): self
{
if (!$this->images->contains($image)) {
$this->images[] = $image;
$image->setProduct($this);
}
return $this;
}
public function removeImage(ImageProduct $image): self
{
if ($this->images->removeElement($image)) {
// set the owning side to null (unless already changed)
if ($image->getProduct() === $this) {
$image->setProduct(null);
}
}
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return Collection|ProductVariant[]
*/
public function getProductVariants(): Collection
{
return $this->productVariants;
}
public function addProductVariant(ProductVariant $productVariant): self
{
if (!$this->productVariants->contains($productVariant)) {
$this->productVariants[] = $productVariant;
$productVariant->setProduct($this);
}
return $this;
}
public function removeProductVariant(ProductVariant $productVariant): self
{
if ($this->productVariants->removeElement($productVariant)) {
// set the owning side to null (unless already changed)
if ($productVariant->getProduct() === $this) {
$productVariant->setProduct(null);
}
}
return $this;
}
public function getIsPriceReducedPerPercent(): ?bool
{
return $this->isPriceReducedPerPercent;
}
public function setIsPriceReducedPerPercent(?bool $isPriceReducedPerPercent): self
{
$this->isPriceReducedPerPercent = $isPriceReducedPerPercent;
return $this;
}
public function getPercentReduction(): ?float
{
return $this->percentReduction;
}
public function setPercentReduction(?float $percentReduction): self
{
$this->percentReduction = $percentReduction;
return $this;
}
public function getSkuCode(): ?string
{
return $this->skuCode;
}
public function setSkuCode(?string $skuCode): self
{
$this->skuCode = $skuCode;
return $this;
}
/**
* @return Collection|OrderItem[]
*/
public function getOrderItems(): Collection
{
return $this->orderItems;
}
public function addOrderItem(OrderItem $orderItem): self
{
if (!$this->orderItems->contains($orderItem)) {
$this->orderItems[] = $orderItem;
$orderItem->setProduct($this);
}
return $this;
}
public function removeOrderItem(OrderItem $orderItem): self
{
if ($this->orderItems->removeElement($orderItem)) {
// set the owning side to null (unless already changed)
if ($orderItem->getProduct() === $this) {
$orderItem->setProduct(null);
}
}
return $this;
}
public function getPromotion(): ?Promotion
{
return $this->promotion;
}
public function setPromotion(?Promotion $promotion): self
{
$this->promotion = $promotion;
return $this;
}
#[Groups(['read', 'readDeep'])]
public function getFinalPrice(){
$finalPrice = $this->getPrice();
if($this->getTypeReduction() and $this->getValueReduction()){
if($this->getTypeReduction() == "percent"){
$finalPrice = $finalPrice - ($finalPrice * $this->getValueReduction() / 100);
return $finalPrice;
}else{
$finalPrice = $finalPrice - $this->getValueReduction();
return $finalPrice;
}
}
elseif($this->getPromotion()){
if($this->getPromotion()->getType()=="percent"){
$reduction = ($this->getPrice() / 100) * $this->getPromotion()->getValue();
$finalPrice = $this->getPrice() - $reduction;
}else{
$finalPrice = $this->getPrice() - $this->getPromotion()->getValue();
}
return $finalPrice;
}
return $this->price - $this->getReduction() ;
}
public function getVendor(): ?Vendor
{
return $this->vendor;
}
public function setVendor(?Vendor $vendor): self
{
$this->vendor = $vendor;
return $this;
}
public function getBrand(): ?Brand
{
return $this->brand;
}
public function setBrand(?Brand $brand): self
{
$this->brand = $brand;
return $this;
}
public function getShortDescription(): ?string
{
return $this->shortDescription;
}
public function setShortDescription(?string $shortDescription): self
{
$this->shortDescription = $shortDescription;
return $this;
}
public function getIsPublished(): ?bool
{
return $this->isPublished;
}
public function setIsPublished(?bool $isPublished): self
{
$this->isPublished = $isPublished;
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setProduct($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getProduct() === $this) {
$comment->setProduct(null);
}
}
return $this;
}
public function getStars5(){
//for 5 stars
$stars5=0;
foreach($this->comments as $singleComment){
if($singleComment->getRating() == 5){
$stars5 = $stars5 + 1;
}
}
return $stars5;
}
public function getStars4(){
//for 4 stars
$stars4=0;
foreach($this->comments as $singleComment){
if($singleComment->getRating() == 4){
$stars4 = $stars4 + 1;
}
}
return $stars4;
}
public function getStars3(){
//for 3 stars
$stars3=0;
foreach($this->comments as $singleComment){
if($singleComment->getRating() == 3){
$stars3 = $stars3 + 1;
}
}
return $stars3;
}
public function getStars2(){
//for 2 stars
$stars2=0;
foreach($this->comments as $singleComment){
if($singleComment->getRating() == 2){
$stars2 = $stars2 + 1;
}
}
return $stars2;
}
public function getStars1(){
//for 5 stars
$stars1=0;
foreach($this->comments as $singleComment){
if($singleComment->getRating() == 1){
$stars1 = $stars1 + 1;
}
}
return $stars1;
}
public function getRating(){
$topRating = 0;
$totalRating=0;
$stars5 = $this->getStars5();
$stars4 = $this->getStars4();
$stars3 = $this->getStars3();
$stars2 = $this->getStars2();
$stars1 = $this->getStars1();
$topRating = ($stars1 * 1 ) + ($stars2 * 2 ) + ($stars3 * 3 ) + ($stars4 * 4 )+ ($stars5 * 5 );
$totalRating = $stars1 + $stars2 +$stars3 + $stars4 + $stars5;
$result = 0;
if($totalRating > 0){
$result = $topRating / $totalRating;
}
return $result;
}
public function getSkuCodeShop(): ?string
{
if(!$this->skuCodeShop){
return $this->skuCodeShop = "OM".$this->createdAt->format("ymdhs").$this->id;
}
return $this->skuCodeShop;
}
public function setSkuCodeShop(?string $skuCodeShop): self
{
$this->skuCodeShop = $skuCodeShop;
return $this;
}
public function addCategoriesProduct(CategoryProduct $categoriesProduct): self
{
if (!$this->categoriesProduct->contains($categoriesProduct)) {
$this->categoriesProduct[] = $categoriesProduct;
}
return $this;
}
public function removeCategoriesProduct(CategoryProduct $categoriesProduct): self
{
$this->categoriesProduct->removeElement($categoriesProduct);
return $this;
}
public function getEndAt(): ?\DateTimeImmutable
{
return $this->endAt;
}
public function setEndAt(?\DateTimeImmutable $endAt): self
{
$this->endAt = $endAt;
return $this;
}
public function getParentCategory(): ?CategoryProduct
{
return $this->parentCategory;
}
public function setParentCategory(?CategoryProduct $parentCategory): self
{
$this->parentCategory = $parentCategory;
return $this;
}
public function getClonedProduct(): ?self
{
return $this->clonedProduct;
}
public function setClonedProduct(?self $clonedProduct): self
{
$this->clonedProduct = $clonedProduct;
return $this;
}
public function getTypeReduction(): ?string
{
return $this->typeReduction;
}
public function setTypeReduction(?string $typeReduction): self
{
$this->typeReduction = $typeReduction;
return $this;
}
public function getValueReduction(): ?float
{
return $this->valueReduction;
}
public function setValueReduction(?float $valueReduction): self
{
$this->valueReduction = $valueReduction;
return $this;
}
/**
* @return Collection<int, ProductSubscription>
*/
public function getProductSubscriptions(): Collection
{
return $this->productSubscriptions;
}
public function addProductSubscription(ProductSubscription $productSubscription): self
{
if (!$this->productSubscriptions->contains($productSubscription)) {
$this->productSubscriptions->add($productSubscription);
$productSubscription->setProduct($this);
}
return $this;
}
public function removeProductSubscription(ProductSubscription $productSubscription): self
{
if ($this->productSubscriptions->removeElement($productSubscription)) {
// set the owning side to null (unless already changed)
if ($productSubscription->getProduct() === $this) {
$productSubscription->setProduct(null);
}
}
return $this;
}
public function getSubscriptionMonthlyPrice(): ?float
{
return $this->subscriptionMonthlyPrice;
}
public function setSubscriptionMonthlyPrice(?float $subscriptionMonthlyPrice): self
{
$this->subscriptionMonthlyPrice = $subscriptionMonthlyPrice;
return $this;
}
public function getSubscriptionYearlyPrice(): ?float
{
return $this->subscriptionYearlyPrice;
}
public function setSubscriptionYearlyPrice(?float $subscriptionYearlyPrice): self
{
$this->subscriptionYearlyPrice = $subscriptionYearlyPrice;
return $this;
}
public function getStore(): ?Store
{
return $this->store;
}
public function setStore(?Store $store): self
{
$this->store = $store;
return $this;
}
/**
* Get the value of deletedAt
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set the value of deletedAt
*
* @return self
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* @return Collection<int, ProductPack>
*/
public function getChildrenProductsPack(): Collection
{
return $this->childrenProductsPack;
}
public function addChildrenProductsPack(ProductPack $childrenPackProduct): self
{
if (!$this->childrenProductsPack->contains($childrenPackProduct)) {
$this->childrenProductsPack->add($childrenPackProduct);
$childrenPackProduct->setParentProduct($this);
}
return $this;
}
public function removeChildrenProductsPack(ProductPack $childrenPackProduct): self
{
if ($this->childrenProductsPack->removeElement($childrenPackProduct)) {
// set the owning side to null (unless already changed)
if ($childrenPackProduct->getParentProduct() === $this) {
$childrenPackProduct->setParentProduct(null);
}
}
return $this;
}
public function isLabelPriceFrom(): ?bool
{
return $this->labelPriceFrom;
}
public function setLabelPriceFrom(?bool $labelPriceFrom): self
{
$this->labelPriceFrom = $labelPriceFrom;
return $this;
}
#[Groups(['read', 'readDeep'])]
public function getDefaultQuantity()
{
if($this->getProductType() == "pack"){
$quantity = 0;
foreach($this->getChildrenProductsPack() as $childrenProduct){
$quantity = $quantity + $childrenProduct->getQuantity();
}
return $quantity;
}
return 1;
}
public function getAttributes(){
$attributes = [];
if($this->productType == "variable"){
foreach($this->attributValues as $singleAttrValue){
if(!in_array($singleAttrValue->getAttribut()->getName(),$attributes)){
$attributes[] =$singleAttrValue->getAttribut()->getName();
}
}
}
return $attributes;
}
public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}
/**
* @return Collection<int, ShippingMethod>
*/
public function getIncludedShippingMethods(): Collection
{
return $this->includedShippingMethods;
}
public function addIncludedShippingMethod(ShippingMethod $includedShippingMethod): static
{
if (!$this->includedShippingMethods->contains($includedShippingMethod)) {
$this->includedShippingMethods->add($includedShippingMethod);
}
return $this;
}
public function removeIncludedShippingMethod(ShippingMethod $includedShippingMethod): static
{
$this->includedShippingMethods->removeElement($includedShippingMethod);
return $this;
}
public function getMetaData(): ?array
{
return $this->metaData;
}
public function setMetaData(?array $metaData): static
{
$this->metaData = $metaData;
return $this;
}
public function getDefaultCurrency(): ?string
{
return $this->defaultCurrency;
}
public function setDefaultCurrency(?string $defaultCurrency): static
{
$this->defaultCurrency = $defaultCurrency;
return $this;
}
/**
* @return Collection<int, PaymentMethod>
*/
public function getIncludedPaymentMethods(): Collection
{
return $this->includedPaymentMethods;
}
public function addIncludedPaymentMethod(PaymentMethod $includedPaymentMethod): static
{
if (!$this->includedPaymentMethods->contains($includedPaymentMethod)) {
$this->includedPaymentMethods->add($includedPaymentMethod);
}
return $this;
}
public function removeIncludedPaymentMethod(PaymentMethod $includedPaymentMethod): static
{
$this->includedPaymentMethods->removeElement($includedPaymentMethod);
return $this;
}
public function getVideo(): ?string
{
return $this->video;
}
public function setVideo(?string $video): static
{
$this->video = $video;
return $this;
}
public function getVideoThumbnail(): ?string
{
return $this->videoThumbnail;
}
public function setVideoThumbnail(?string $videoThumbnail): static
{
$this->videoThumbnail = $videoThumbnail;
return $this;
}
public function getCostPrice(): ?float
{
return $this->costPrice;
}
public function setCostPrice(?float $costPrice): static
{
$this->costPrice = $costPrice;
return $this;
}
/**
* @return Collection<int, Country>
*/
public function getShipToCountries(): Collection
{
return $this->shipToCountries;
}
public function addShipToCountry(Country $shipToCountry): static
{
if (!$this->shipToCountries->contains($shipToCountry)) {
$this->shipToCountries->add($shipToCountry);
}
return $this;
}
public function removeShipToCountry(Country $shipToCountry): static
{
$this->shipToCountries->removeElement($shipToCountry);
return $this;
}
/**
* Get the value of position
*/
public function getPosition()
{
return $this->position;
}
/**
* Set the value of position
*
* @return self
*/
public function setPosition($position)
{
$this->position = $position;
return $this;
}
}