src/Entity/ECommerce/Product.php line 36

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