src/Model/Product/AccessoryPart.php line 21

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Enterprise License (PEL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PEL
  13.  */
  14. namespace App\Model\Product;
  15. use Pimcore\Model\DataObject\Car\Listing;
  16. use Pimcore\Model\DataObject\Data\Hotspotimage;
  17. class AccessoryPart extends \Pimcore\Model\DataObject\AccessoryPart
  18. {
  19.     /**
  20.      * @return string
  21.      */
  22.     public function getOSName(): ?string
  23.     {
  24.         return $this->getGeneratedName();
  25.     }
  26.     public function getProductName($language null) {
  27.         return
  28.             ($this->getSeries() ? ($this->getSeries()->getName() . ' ') : '') .
  29.             ($this->getMainCategory() ? ($this->getMainCategory()->getName($language) . ' ') : '') .
  30.             $this->getNameAddition($language)
  31.             ;
  32.     }
  33.     /**
  34.      * @return int|string
  35.      */
  36.     public function getOSProductNumber(): ?string
  37.     {
  38.         return $this->getErpNumber();
  39.     }
  40.     /**
  41.      * @return string
  42.      */
  43.     public function getOSIndexType(): ?string
  44.     {
  45.         return self::OBJECT_TYPE_VARIANT;
  46.     }
  47.     /**
  48.      * @return Hotspotimage|null
  49.      */
  50.     public function getMainImage(): ?Hotspotimage
  51.     {
  52.         return $this->getImage();
  53.     }
  54.     /**
  55.      * @return Category[]
  56.      */
  57.     public function getCategories(): ?array
  58.     {
  59.         return [$this->getMainCategory()];
  60.     }
  61.     /**
  62.      * @return int[]
  63.      *
  64.      * @throws \Exception
  65.      */
  66.     public function getCompatibleToProductIds()
  67.     {
  68.         $paths = [];
  69.         foreach ($this->getCompatibleTo() as $compatible) {
  70.             $paths[] = 'o_path LIKE "' $compatible->getFullPath() . '%"';
  71.         }
  72.         $listing = new Listing();
  73.         $listing->setCondition(implode(' OR '$paths));
  74.         return $listing->loadIdList();
  75.     }
  76. }