src/Model/Product/AbstractProduct.php line 60

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\Bundle\EcommerceFrameworkBundle\PriceSystem\PriceInterface;
  16. use Pimcore\Model\DataObject\Data\Hotspotimage;
  17. abstract class AbstractProduct extends \Pimcore\Bundle\EcommerceFrameworkBundle\Model\AbstractProduct
  18. {
  19.     public function isActive(bool $inProductList = false): bool
  20.     {
  21.         return $this->isPublished();
  22.     }
  23.     public function getPriceSystemName(): ?string
  24.     {
  25.         return 'papyrus';
  26.     }
  27.     public function getOSName(): ?string
  28.     {
  29.         return $this->getName();
  30.     }
  31.     public function getOSProductNumber(): ?string
  32.     {
  33.         return $this->getId();
  34.     }
  35.     public function getOSDefaultPrice($quantityScale = 1): ?PriceInterface
  36.     {
  37.         return $this->getOSPriceInfo($quantityScale)->getDefaultPrice();
  38.     }
  39.     public function getDiscount($quantityScale = 1): int
  40.     {
  41.         return $this->getOSPriceInfo($quantityScale)->getDiscount();
  42.     }
  43.     /**
  44.      * @return Category|null
  45.      */
  46.     public function getMainCategory(): ?Category
  47.     {
  48.         $categories = $this->getCategories();
  49.         $category = reset($categories);
  50.         return $category ?: null;
  51.     }
  52. }