src/Entity/ECommerce/Product.php line 1040

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ECommerce;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JMS\Serializer\Annotation as JMS;
  7. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  8. use App\Entity\ECommerce\Traits\DatesInterface;
  9. use App\Entity\ECommerce\Traits\DatesTrait;
  10. use App\Entity\ECommerce\Traits\RemoteInterface;
  11. use App\Entity\ECommerce\Traits\RemoteTrait;
  12. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  13. use Symfony\Component\Security\Core\User\UserInterface;
  14. /**
  15. * Product
  16. *
  17. * @ORM\Table(name="product",
  18. * indexes={
  19. * @ORM\Index(name="product_title", columns={"title"}),
  20. * @ORM\Index(name="product_search_title", columns={"search_title"}),
  21. * @ORM\Index(name="product_slug", columns={"slug"}),
  22. * @ORM\Index(name="product_id", columns={"id"}),
  23. * @ORM\Index(name="product_remote_id", columns={"remote_id"}),
  24. * @ORM\Index(name="product_dimensions", columns={"inner_diameter_min", "inner_diameter_max", "outer_diameter_min", "outer_diameter_max", "width_min", "width_max"}),
  25. * @ORM\Index(name="title_manufacturer", columns={"title", "manufacturer"})
  26. * },
  27. * uniqueConstraints={})
  28. *
  29. * @ORM\Entity(repositoryClass="App\Repository\ECommerce\ProductRepository")
  30. * @ORM\Cache(usage="READ_ONLY", region="public")
  31. */
  32. class Product implements DatesInterface, RemoteInterface, TranslatableInterface, \Stringable
  33. {
  34. /**
  35. * traits
  36. */
  37. use TranslatableTrait;
  38. use DatesTrait {
  39. DatesTrait::__construct as __D_construct;
  40. }
  41. use RemoteTrait;
  42. /**
  43. * @var int
  44. *
  45. * @ORM\Column(name="id", type="integer")
  46. * @ORM\Id
  47. * @ORM\GeneratedValue(strategy="AUTO")
  48. *
  49. * @JMS\Expose()
  50. * @JMS\Groups({"filter", "depot_products", "depot_product_private", "cart_private", "view_product"})
  51. */
  52. private ?int $id;
  53. /**
  54. * @ORM\Column(name="code", type="string", nullable=true, length=10)
  55. *
  56. * @JMS\Groups({"filter", "depot_products", "depot_product_private", "cart_private", "view_product"})
  57. */
  58. private ?string $code = null;
  59. /**
  60. * @ORM\Column(name="barcode", type="text", nullable=true)
  61. *
  62. * @JMS\Groups({"filter", "depot_products", "depot_product_private", "cart_private", "view_product"})
  63. */
  64. protected ?string $barcode = null;
  65. /**
  66. * @ORM\Column(name="title", type="string", length=255, nullable=false)
  67. *
  68. * @JMS\Expose()
  69. *
  70. * @JMS\Groups({"filter", "depot_products", "depot_product_private", "cart_private", "view_product"})
  71. */
  72. private string $title = '';
  73. /**
  74. * @ORM\Column(name="original_title", type="string", length=255, nullable=true)
  75. */
  76. private ?string $originalTitle = null;
  77. /**
  78. * @ORM\Column(name="search_title", type="string", length=255, nullable=true)
  79. */
  80. private ?string $searchTitle = null;
  81. /**
  82. * @ORM\Column(name="slug", type="string", length=255, nullable=true)
  83. */
  84. private ?string $slug = null;
  85. /**
  86. * @ORM\Column(name="origin", type="string", length=50, nullable=true)
  87. *
  88. * @JMS\Groups({"depot_product_private", "cart_private"})
  89. */
  90. private ?string $origin = null;
  91. /**
  92. * @ORM\Column(name="link", type="string", length=255, nullable=true)
  93. */
  94. private ?string $link = null;
  95. /**
  96. * @var float
  97. *
  98. * @ORM\Column(name="inner_diameter_min", type="float", nullable=true, precision=4, scale=3)
  99. *
  100. * @JMS\Groups({"depot_product_private", "cart_private"})
  101. */
  102. private $innerDiameterMin;
  103. /**
  104. * @var float
  105. *
  106. * @ORM\Column(name="inner_diameter_max", type="float", nullable=true, precision=4, scale=3)
  107. *
  108. * @JMS\Groups({"depot_product_private", "cart_private"})
  109. */
  110. private $innerDiameterMax;
  111. /**
  112. * @var float
  113. *
  114. * @ORM\Column(name="outer_diameter_min", type="float", nullable=true, precision=4, scale=3)
  115. *
  116. * @JMS\Groups({"depot_product_private", "cart_private"})
  117. */
  118. private $outerDiameterMin;
  119. /**
  120. * @var float
  121. *
  122. * @ORM\Column(name="outer_diameter_max", type="float", nullable=true, precision=4, scale=3)
  123. *
  124. * @JMS\Groups({"depot_product_private", "cart_private"})
  125. */
  126. private $outerDiameterMax;
  127. /**
  128. * @var float
  129. *
  130. * @ORM\Column(name="width_min", type="float", nullable=true, precision=4, scale=3)
  131. *
  132. * @JMS\Groups({"depot_product_private", "cart_private"})
  133. */
  134. private $widthMin;
  135. /**
  136. * @var float
  137. *
  138. * @ORM\Column(name="width_max", type="float", nullable=true, precision=4, scale=3)
  139. *
  140. * @JMS\Groups({"depot_product_private", "cart_private"})
  141. */
  142. private $widthMax;
  143. /**
  144. * @var float
  145. *
  146. * @ORM\Column(name="weight", type="float", nullable=true)
  147. *
  148. * @JMS\Groups({"depot_products", "depot_product_private", "cart_private"})
  149. */
  150. private $weight;
  151. /**
  152. * @var float
  153. *
  154. * @ORM\Column(name="gross_price", type="decimal", precision=18, scale=4, nullable=true)
  155. */
  156. private $grossPrice;
  157. /**
  158. * @var float
  159. *
  160. * @ORM\Column(name="minimal_quantity", type="float", nullable=true)
  161. *
  162. * @JMS\Groups({"depot_product_private", "cart_private"})
  163. */
  164. private $minimalQuantity;
  165. /**
  166. * @var bool
  167. *
  168. * @ORM\Column(name="disabled", type="boolean", nullable=true)
  169. *
  170. * @JMS\Groups({"depot_product_private", "cart_private"})
  171. */
  172. private bool $disabled;
  173. /**
  174. * @ORM\OneToMany(targetEntity="App\Entity\ECommerce\ProductPhoto", mappedBy="product", cascade={"ALL"}, fetch="EAGER")
  175. *
  176. * @JMS\Groups({"depot_products", "depot_product_private", "cart_private", "product_photo"})
  177. */
  178. private Collection $photos;
  179. /**
  180. * @ORM\OneToMany(targetEntity="App\Entity\ECommerce\ProductDocument", mappedBy="product", cascade={"all"}, fetch="EAGER")
  181. *
  182. * @JMS\Groups({"depot_products", "depot_product_private", "cart_private", "product_document"})
  183. */
  184. private Collection $documents;
  185. /**
  186. * @ORM\ManyToOne(targetEntity="App\Entity\ECommerce\ProductCategory", inversedBy="products")
  187. * @ORM\JoinColumn(name="category", referencedColumnName="id", nullable=true)
  188. *
  189. * @JMS\Groups({"depot_products", "depot_product_private", "cart_private", "view_product"})
  190. */
  191. private ?ProductCategory $category;
  192. /**
  193. * @ORM\ManyToOne(targetEntity="App\Entity\ECommerce\ProductSubCategory", inversedBy="products")
  194. * @ORM\JoinColumn(name="sub_category", referencedColumnName="id", nullable=true)
  195. *
  196. * @JMS\Groups({"depot_products", "depot_product_private", "cart_private", "view_product"})
  197. */
  198. private ?ProductSubCategory $subCategory;
  199. /**
  200. * @ORM\ManyToOne(targetEntity="App\Entity\ECommerce\ProductGroup", inversedBy="products")
  201. * @ORM\JoinColumn(name="product_group", referencedColumnName="id", nullable=true)
  202. *
  203. * @JMS\Groups({"depot_products", "depot_product_private", "cart_private"})
  204. */
  205. private ?ProductGroup $group;
  206. /**
  207. * @ORM\ManyToOne(targetEntity="App\Entity\ECommerce\ProductManufacturer", inversedBy="products")
  208. * @ORM\JoinColumn(name="manufacturer", referencedColumnName="id", nullable=true)
  209. *
  210. * @JMS\Groups({"depot_products", "depot_product_private", "cart_private", "view_product"})
  211. */
  212. private ProductManufacturer $manufacturer;
  213. /**
  214. *
  215. * @ORM\OneToMany(targetEntity="App\Entity\ECommerce\DepotProduct", mappedBy="product", cascade={"all"})
  216. * @JMS\Groups({"depot_products", "depot_product_private"})
  217. */
  218. private Collection $quantities;
  219. /**
  220. * @ORM\OneToMany(targetEntity="App\Entity\ECommerce\ProductAlternative", mappedBy="product", cascade={"all"})
  221. * @ORM\OrderBy({"title" = "ASC"})
  222. *
  223. * @JMS\Groups({"depot_product_private", "cart_private"})
  224. */
  225. private Collection $alternatives;
  226. /**
  227. * @ORM\ManyToMany(targetEntity="App\Entity\ECommerce\ProductInfo")
  228. * @ORM\JoinTable(name="product_product_info",
  229. * joinColumns={@ORM\JoinColumn(name="product", referencedColumnName="id")},
  230. * inverseJoinColumns={@ORM\JoinColumn(name="product_info", referencedColumnName="id")}
  231. * )
  232. */
  233. private Collection $infoCodes;
  234. /**
  235. * @ORM\ManyToOne(targetEntity="App\Entity\ECommerce\Unit", inversedBy="products")
  236. * @ORM\JoinColumn(name="unit_of_measurement", referencedColumnName="id", nullable=true)
  237. *
  238. * @JMS\Groups({"depot_products", "depot_product_private", "cart_private"})
  239. */
  240. private ?Unit $unitOfMeasurement;
  241. /**
  242. * Constructor
  243. */
  244. public function __construct()
  245. {
  246. $this->__D_construct();
  247. $this->photos = new ArrayCollection();
  248. $this->documents = new ArrayCollection();
  249. $this->quantities = new ArrayCollection();
  250. $this->alternatives = new ArrayCollection();
  251. }
  252. public function __toString(): string
  253. {
  254. return (string)$this->id;
  255. }
  256. /**
  257. * Get id
  258. *
  259. * @return int
  260. */
  261. public function getId(): ?int
  262. {
  263. return $this->id;
  264. }
  265. /**
  266. * Set title
  267. *
  268. * @param string $title
  269. */
  270. public function setTitle($title): self
  271. {
  272. $this->title = $title;
  273. return $this;
  274. }
  275. /**
  276. * Get title
  277. *
  278. * @return string
  279. */
  280. public function getTitle(): ?string
  281. {
  282. return $this->title;
  283. }
  284. /**
  285. * Set originalTitle
  286. *
  287. * @param string $originalTitle
  288. */
  289. public function setOriginalTitle($originalTitle): self
  290. {
  291. $this->originalTitle = $originalTitle;
  292. return $this;
  293. }
  294. /**
  295. * Get originalTitle
  296. *
  297. * @return string
  298. */
  299. public function getOriginalTitle(): ?string
  300. {
  301. return $this->originalTitle;
  302. }
  303. /**
  304. * Set searchTitle
  305. *
  306. * @param string|null $searchTitle
  307. */
  308. public function setSearchTitle($searchTitle = null): self
  309. {
  310. $this->searchTitle = $searchTitle;
  311. return $this;
  312. }
  313. /**
  314. * Get searchTitle
  315. */
  316. public function getSearchTitle(): ?string
  317. {
  318. return $this->searchTitle;
  319. }
  320. /**
  321. * Set slug
  322. *
  323. *
  324. */
  325. public function setSlug(string $slug): self
  326. {
  327. $this->slug = $slug;
  328. return $this;
  329. }
  330. public function getSlug(): string
  331. {
  332. return $this->slug;
  333. }
  334. /**
  335. * Set alternatives
  336. *
  337. * @param Collection $alternatives
  338. */
  339. public function setAlternatives($alternatives): self
  340. {
  341. $this->alternatives = $alternatives;
  342. return $this;
  343. }
  344. /**
  345. * Add alternative
  346. *
  347. *
  348. */
  349. public function addAlternative(ProductAlternative $alternative): self
  350. {
  351. $this->alternatives[] = $alternative;
  352. return $this;
  353. }
  354. /**
  355. * Remove alternative
  356. */
  357. public function removeAlternative(ProductAlternative $alternative): void
  358. {
  359. $this->alternatives->removeElement($alternative);
  360. }
  361. /**
  362. * Get alternatives
  363. *
  364. * @return Collection
  365. */
  366. public function getAlternatives()
  367. {
  368. return $this->alternatives;
  369. }
  370. /**
  371. * Set unitOfMeasurement
  372. *
  373. *
  374. */
  375. public function setUnitOfMeasurement(Unit $unitOfMeasurement): self
  376. {
  377. $this->unitOfMeasurement = $unitOfMeasurement;
  378. return $this;
  379. }
  380. /**
  381. * Get unitOfMeasurement
  382. *
  383. * @return Unit
  384. */
  385. public function getUnitOfMeasurement(): ?Unit
  386. {
  387. return $this->unitOfMeasurement;
  388. }
  389. /**
  390. * Set origin
  391. *
  392. * @param string $origin
  393. */
  394. public function setOrigin($origin): self
  395. {
  396. $this->origin = $origin;
  397. return $this;
  398. }
  399. /**
  400. * Get origin
  401. *
  402. * @return string
  403. */
  404. public function getOrigin(): ?string
  405. {
  406. return $this->origin;
  407. }
  408. /**
  409. * Set link
  410. *
  411. * @param string $link
  412. */
  413. public function setLink($link): self
  414. {
  415. $this->link = $link;
  416. return $this;
  417. }
  418. /**
  419. * Get link
  420. *
  421. * @return string
  422. */
  423. public function getLink(): ?string
  424. {
  425. return $this->link;
  426. }
  427. /**
  428. * Set innerDiameter
  429. *
  430. *
  431. */
  432. public function setInnerDiameter(string $innerDiameter): self
  433. {
  434. $dimensions = explode('/', $innerDiameter);
  435. $this->innerDiameterMin = array_shift($dimensions);
  436. if (count($dimensions)) {
  437. $this->innerDiameterMax = array_shift($dimensions);
  438. }
  439. return $this;
  440. }
  441. /**
  442. * Get innerDiameter
  443. */
  444. public function getInnerDiameter(): string
  445. {
  446. return implode('/', array_filter([$this->innerDiameterMin, $this->innerDiameterMax]));
  447. }
  448. /**
  449. * Set innerDiameterMin
  450. *
  451. * @param float $innerDiameterMin
  452. */
  453. public function setInnerDiameterMin($innerDiameterMin): self
  454. {
  455. $this->innerDiameterMin = $innerDiameterMin;
  456. return $this;
  457. }
  458. /**
  459. * Get innerDiameterMin
  460. *
  461. * @return float
  462. */
  463. public function getInnerDiameterMin(): ?float
  464. {
  465. return $this->innerDiameterMin;
  466. }
  467. /**
  468. * Set innerDiameterMax
  469. *
  470. * @param float $innerDiameterMax
  471. */
  472. public function setInnerDiameterMax($innerDiameterMax): self
  473. {
  474. $this->innerDiameterMax = $innerDiameterMax;
  475. return $this;
  476. }
  477. /**
  478. * Get innerDiameterMax
  479. *
  480. * @return float
  481. */
  482. public function getInnerDiameterMax(): ?float
  483. {
  484. return $this->innerDiameterMax;
  485. }
  486. /**
  487. * Set outerDiameter
  488. *
  489. * @param float $outerDiameter
  490. */
  491. public function setOuterDiameter($outerDiameter): self
  492. {
  493. $dimensions = explode('/', $outerDiameter);
  494. $this->outerDiameterMin = array_shift($dimensions);
  495. if (count($dimensions)) {
  496. $this->outerDiameterMax = array_shift($dimensions);
  497. }
  498. return $this;
  499. }
  500. /**
  501. * Get outerDiameter
  502. */
  503. public function getOuterDiameter(): string
  504. {
  505. return implode('/', array_filter([$this->outerDiameterMin, $this->outerDiameterMax]));
  506. }
  507. /**
  508. * Set outerDiameterMin
  509. *
  510. * @param float $outerDiameterMin
  511. */
  512. public function setOuterDiameterMin($outerDiameterMin): self
  513. {
  514. $this->outerDiameterMin = $outerDiameterMin;
  515. return $this;
  516. }
  517. /**
  518. * Get outerDiameterMin
  519. *
  520. * @return float
  521. */
  522. public function getOuterDiameterMin(): ?float
  523. {
  524. return $this->outerDiameterMin;
  525. }
  526. /**
  527. * Set outerDiameterMax
  528. *
  529. * @param float $outerDiameterMax
  530. */
  531. public function setOuterDiameterMax($outerDiameterMax): self
  532. {
  533. $this->outerDiameterMax = $outerDiameterMax;
  534. return $this;
  535. }
  536. /**
  537. * Get outerDiameterMax
  538. *
  539. * @return float
  540. */
  541. public function getOuterDiameterMax(): ?float
  542. {
  543. return $this->outerDiameterMax;
  544. }
  545. /**
  546. * Set widthMin
  547. *
  548. * @param float $widthMin
  549. */
  550. public function setWidthMin($widthMin): self
  551. {
  552. $this->widthMin = $widthMin;
  553. return $this;
  554. }
  555. /**
  556. * Get widthMin
  557. *
  558. * @return float
  559. */
  560. public function getWidthMin(): ?float
  561. {
  562. return (float)$this->widthMin;
  563. }
  564. /**
  565. * Set widthMax
  566. *
  567. * @param float $widthMax
  568. */
  569. public function setWidthMax($widthMax): self
  570. {
  571. $this->widthMax = $widthMax;
  572. return $this;
  573. }
  574. /**
  575. * Get widthMax
  576. *
  577. * @return float
  578. */
  579. public function getWidthMax(): ?float
  580. {
  581. return $this->widthMax;
  582. }
  583. /**
  584. * Set width
  585. *
  586. * @param float $width
  587. */
  588. public function setWidth($width): self
  589. {
  590. $dimensions = explode('/', $width);
  591. $this->widthMin = array_shift($dimensions);
  592. if (count($dimensions)) {
  593. $this->widthMax = array_shift($dimensions);
  594. }
  595. return $this;
  596. }
  597. /**
  598. * Get width
  599. */
  600. public function getWidth(): string
  601. {
  602. return implode('/', array_filter([$this->widthMin, $this->widthMax]));
  603. }
  604. /**
  605. * Get dimensions string
  606. */
  607. public function getDimensions(): string
  608. {
  609. return implode(' x ', array_filter([$this->getInnerDiameter(), $this->getOuterDiameter(), $this->getWidth()]));
  610. }
  611. /**
  612. * Set weight
  613. *
  614. * @param float $weight
  615. */
  616. public function setWeight($weight): self
  617. {
  618. $this->weight = $weight;
  619. return $this;
  620. }
  621. /**
  622. * Get weight
  623. *
  624. * @return float
  625. */
  626. public function getWeight(): ?float
  627. {
  628. return $this->weight;
  629. }
  630. /**
  631. * Set grossPrice
  632. *
  633. * @param float $grossPrice
  634. */
  635. public function setGrossPrice($grossPrice): self
  636. {
  637. $this->grossPrice = $grossPrice;
  638. return $this;
  639. }
  640. /**
  641. * Get grossPrice
  642. *
  643. * @return float
  644. */
  645. public function getGrossPrice(): ?float
  646. {
  647. return $this->grossPrice;
  648. }
  649. /**
  650. * Set minimalQuantity
  651. *
  652. * @param float $minimalQuantity
  653. */
  654. public function setMinimalQuantity($minimalQuantity): self
  655. {
  656. $this->minimalQuantity = $minimalQuantity;
  657. return $this;
  658. }
  659. /**
  660. * Get minimalQuantity
  661. *
  662. * @return float
  663. */
  664. public function getMinimalQuantity(): ?float
  665. {
  666. return $this->minimalQuantity;
  667. }
  668. /**
  669. * Set code
  670. *
  671. * @param string $code
  672. */
  673. public function setCode($code): self
  674. {
  675. $this->code = $code;
  676. return $this;
  677. }
  678. /**
  679. * Get code
  680. *
  681. * @return string
  682. */
  683. public function getCode(): ?string
  684. {
  685. return $this->code;
  686. }
  687. /**
  688. * Set barcode
  689. *
  690. *
  691. */
  692. public function setBarcode(string $barcode): self
  693. {
  694. $this->barcode = $barcode;
  695. return $this;
  696. }
  697. /**
  698. * Get barcode
  699. */
  700. public function getBarcode(): ?string
  701. {
  702. return $this->barcode;
  703. }
  704. /**
  705. * Set disabled
  706. *
  707. *
  708. */
  709. public function setDisabled(bool $disabled): self
  710. {
  711. $this->disabled = $disabled;
  712. return $this;
  713. }
  714. /**
  715. * Is disabled
  716. */
  717. public function isDisabled(): bool
  718. {
  719. return $this->disabled;
  720. }
  721. /**
  722. * Set category
  723. *
  724. *
  725. */
  726. public function setCategory(ProductCategory $category = null): self
  727. {
  728. $this->category = $category instanceof \App\Entity\ECommerce\ProductCategory ? $category->addProduct($this) : null;
  729. return $this;
  730. }
  731. /**
  732. * Get category
  733. *
  734. * @return ProductCategory
  735. */
  736. public function getCategory(): ?ProductCategory
  737. {
  738. return $this->category;
  739. }
  740. /**
  741. * Set group
  742. *
  743. *
  744. */
  745. public function setGroup(ProductGroup $group = null): self
  746. {
  747. $this->group = $group;
  748. return $this;
  749. }
  750. /**
  751. * Get group
  752. *
  753. * @return ProductGroup
  754. */
  755. public function getGroup(): ?ProductGroup
  756. {
  757. return $this->group;
  758. }
  759. /**
  760. * Set manufacturer
  761. *
  762. *
  763. */
  764. public function setManufacturer(ProductManufacturer $manufacturer = null): self
  765. {
  766. $this->manufacturer = $manufacturer;
  767. return $this;
  768. }
  769. /**
  770. * Get manufacturer
  771. */
  772. public function getManufacturer(): ?ProductManufacturer
  773. {
  774. return $this->manufacturer;
  775. }
  776. /**
  777. * Add photo
  778. *
  779. *
  780. */
  781. public function addPhoto(ProductPhoto $photo): self
  782. {
  783. $this->photos[] = $photo;
  784. return $this;
  785. }
  786. /**
  787. * Remove photo
  788. */
  789. public function removePhoto(ProductPhoto $photo): void
  790. {
  791. $this->photos->removeElement($photo);
  792. }
  793. /**
  794. * Get photos
  795. */
  796. public function getPhotos(): Collection
  797. {
  798. return $this->photos;
  799. }
  800. /**
  801. * Add document
  802. *
  803. *
  804. */
  805. public function addDocument(ProductDocument $document): self
  806. {
  807. $this->documents[] = $document;
  808. return $this;
  809. }
  810. /**
  811. * Remove document
  812. */
  813. public function removeDocument(ProductDocument $document): void
  814. {
  815. $this->documents->removeElement($document);
  816. }
  817. /**
  818. * Get documents
  819. */
  820. public function getDocuments(): Collection
  821. {
  822. return $this->documents;
  823. }
  824. /**
  825. * Get documents
  826. *
  827. * @param string|null $locale
  828. */
  829. public function getPublicDocuments(string $locale = null): Collection
  830. {
  831. return $this->documents->filter(static fn(ProductDocument $document): bool => $document->getDocument()->getEnabled());
  832. }
  833. /**
  834. * Add quantity
  835. *
  836. *
  837. */
  838. public function addQuantity(DepotProduct $quantity): self
  839. {
  840. $this->quantities[] = $quantity;
  841. return $this;
  842. }
  843. /**
  844. * Remove quantity
  845. */
  846. public function removeQuantity(DepotProduct $quantity): void
  847. {
  848. $this->quantities->removeElement($quantity);
  849. }
  850. /**
  851. * Get quantities
  852. */
  853. public function getQuantities(): Collection
  854. {
  855. return $this->quantities;
  856. }
  857. /**
  858. * Filter quantities by user
  859. */
  860. public function filterUserQuantities(UserInterface $user): void
  861. {
  862. $this->quantities = $this->quantities->filter(static fn(DepotProduct $depotProduct) => $depotProduct->getDepot()->getUsers()->contains($user));
  863. }
  864. /**
  865. * Add infoCode
  866. *
  867. *
  868. */
  869. public function addInfoCode(ProductInfo $infoCode): self
  870. {
  871. $this->infoCodes[] = $infoCode;
  872. return $this;
  873. }
  874. /**
  875. * Remove infoCode
  876. */
  877. public function removeInfoCode(ProductInfo $infoCode): void
  878. {
  879. $this->infoCodes->removeElement($infoCode);
  880. }
  881. /**
  882. * Get infoCodes
  883. */
  884. public function getInfoCodes(): Collection
  885. {
  886. return $this->infoCodes;
  887. }
  888. /**
  889. * Set subCategory
  890. *
  891. *
  892. */
  893. public function setSubCategory(ProductSubCategory $subCategory = null): self
  894. {
  895. $this->subCategory = $subCategory;
  896. return $this;
  897. }
  898. /**
  899. * Get subCategory
  900. *
  901. * @return ProductSubCategory
  902. */
  903. public function getSubCategory(): ?ProductSubCategory
  904. {
  905. return $this->subCategory;
  906. }
  907. }