<?php
namespace App\AtechNet\CoreBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\JoinTable;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OrderBy;
use Doctrine\ORM\Mapping\Table as Table;
/**
* CategoryPage
*
* @Table(name="pages_category")
* @Entity(repositoryClass="App\AtechNet\CoreBundle\Repository\CategoryPageRepository")
*/
class CategoryPage extends AbstractPage
{
public const CATEGORY_TYPE_PRODUCT = 1;
public const CATEGORY_TYPE_BLOG = 2;
public const SK_CATEGORYPAGE_ID_NOTEBOOK = 5;
public const SK_CATEGORYPAGE_ID_PC = 4;
public const SK_CATEGORYPAGE_ID_MONITOR = 6;
public const SK_CATEGORYPAGE_ID_MOBIL = 236;
public const SK_CATEGORYPAGE_ID_TABLET = 269;
public const SK_CATEGORYPAGE_ID_SMARTWATCH = 272;
public const SK_CATEGORYPAGE_ID_ELECTRIC_SCOOTER = 493;
public const HU_CATEGORYPAGE_ID_NOTEBOOK = 56;
public const HU_CATEGORYPAGE_ID_PC = 48;
public const HU_CATEGORYPAGE_ID_MONITOR = 78;
public const HU_CATEGORYPAGE_ID_MOBIL = 235;
public const HU_CATEGORYPAGE_ID_TABLET = 268;
public const HU_CATEGORYPAGE_ID_SMARTWATCH = 271;
public const HU_CATEGORYPAGE_ID_ELECTRIC_SCOOTER = 492;
public const CZ_CATEGORYPAGE_ID_NOTEBOOK = 130;
public const CZ_CATEGORYPAGE_ID_PC = 122;
public const CZ_CATEGORYPAGE_ID_MONITOR = 149;
public const CZ_CATEGORYPAGE_ID_MOBIL = 239;
public const CZ_CATEGORYPAGE_ID_TABLET = 270;
public const CZ_CATEGORYPAGE_ID_SMARTWATCH = 364;
public const CZ_CATEGORYPAGE_ID_ELECTRIC_SCOOTER = 494;
public const EU_CATEGORYPAGE_ID_NOTEBOOK = 285;
public const EU_CATEGORYPAGE_ID_PC = 277;
public const EU_CATEGORYPAGE_ID_MONITOR = 304;
public const EU_CATEGORYPAGE_ID_MOBIL = 350;
public const EU_CATEGORYPAGE_ID_TABLET = 360;
public const EU_CATEGORYPAGE_ID_SMARTWATCH = 361;
public const EU_CATEGORYPAGE_ID_ELECTRIC_SCOOTER = 598;
public const SK_CATEGORYPAGE_ID_SALE = 622;
public const HU_CATEGORYPAGE_ID_SALE = 621;
public const CZ_CATEGORYPAGE_ID_SALE = 623;
public const EU_CATEGORYPAGE_ID_SALE = 624;
public const MARKETING_FESZT = 659;
public const UJVARI_FURDO_BANNER_SK = 669;
public const UJVARI_FURDO_BANNER_HU = 674;
public const UJVARI_FURDO_BANNER_CZ = 675;
public const PRODUCT_TYPE_NORMAL = 1;
public const PRODUCT_TYPE_PRIORITY = 2;
public const PRODUCT_TYPE_POPULAR = 3;
/**
* @return array
*/
public static function getCategoryTypeChoices(): array
{
return [
self::CATEGORY_TYPE_PRODUCT => 'Product',
self::CATEGORY_TYPE_BLOG => 'Blog',
];
}
public const SALE_CATEGORY_PAGES = [
self::SK_CATEGORYPAGE_ID_SALE,
self::HU_CATEGORYPAGE_ID_SALE,
self::CZ_CATEGORYPAGE_ID_SALE,
self::EU_CATEGORYPAGE_ID_SALE,
//MARKETING FESZT
self::MARKETING_FESZT,
//
self::UJVARI_FURDO_BANNER_SK,
self::UJVARI_FURDO_BANNER_HU,
self::UJVARI_FURDO_BANNER_CZ,
];
private const PRODUCT_TYPE_FILTERS = [
ProductType::PRODUCT_TYPE_ID_NOTEBOOK => [
Attribute::ATTRIBUTE_ID_YEAR_OF_PRODUCTION,
Attribute::ATTRIBUTE_ID_QUALITY,
Attribute::ATTRIBUTE_ID_ACCESSORY_OS,
Attribute::ATTRIBUTE_ID_SCREEN_SIZE,
Attribute::ATTRIBUTE_ID_CPU_MARK,
Attribute::ATTRIBUTE_ID_RAM_SIZE,
Attribute::ATTRIBUTE_ID_SSD,
Attribute::ATTRIBUTE_ID_CPU_NB_FAMILY,
Attribute::ATTRIBUTE_ID_MAXIMUM_RESOLUTION,
Attribute::ATTRIBUTE_ID_CONF_NOTEBOOK_SKIN,
Attribute::ATTRIBUTE_ID_TOUCH_SCREEN,
Attribute::ATTRIBUTE_ID_WEBCAM,
Attribute::ATTRIBUTE_ID_EXTERNAL_CONNECTORS,
Attribute::ATTRIBUTE_ID_NUMPAD,
Attribute::ATTRIBUTE_ID_CPU_GENERATION,
Attribute::ATTRIBUTE_ID_VGA,
Attribute::ATTRIBUTE_ID_MEMORY_TYPE,
Attribute::ATTRIBUTE_ID_DISPLAY_TECHNOLOGY,
Attribute::ATTRIBUTE_ID_OPTICAL_DRIVER,
Attribute::ATTRIBUTE_ID_HDD_25,
Attribute::ATTRIBUTE_ID_BATTERY,
],
ProductType::PRODUCT_TYPE_ID_PC => [
Attribute::ATTRIBUTE_ID_QUALITY,
Attribute::ATTRIBUTE_ID_OPERATING_SYSTEM,
Attribute::ATTRIBUTE_ID_RAM_SIZE,
Attribute::ATTRIBUTE_ID_MEMORY_TYPE,
Attribute::ATTRIBUTE_ID_CPU_PC_FAMILY,
Attribute::ATTRIBUTE_ID_CPU_GENERATION,
Attribute::ATTRIBUTE_ID_HDD_25,
Attribute::ATTRIBUTE_ID_SSD,
Attribute::ATTRIBUTE_ID_FORM,
Attribute::ATTRIBUTE_ID_EXTERNAL_CONNECTORS,
Attribute::ATTRIBUTE_ID_OPTICAL_DRIVER,
],
ProductType::PRODUCT_TYPE_ID_MONITOR => [
Attribute::ATTRIBUTE_ID_QUALITY,
Attribute::ATTRIBUTE_ID_SCREEN_SIZE,
Attribute::ATTRIBUTE_ID_MAXIMUM_RESOLUTION,
Attribute::ATTRIBUTE_ID_ASPECT_RATIO,
Attribute::ATTRIBUTE_ID_CONTRAST,
Attribute::ATTRIBUTE_ID_SCREEN_REFRESH_RATE,
Attribute::ATTRIBUTE_ID_RESPONSE_TIME,
Attribute::ATTRIBUTE_ID_GRAPHIC_INPUTS,
Attribute::ATTRIBUTE_ID_VESA,
Attribute::ATTRIBUTE_ID_SPEAKER,
Attribute::ATTRIBUTE_ID_DISPLAY_TECHNOLOGY,
Attribute::ATTRIBUTE_ID_TOUCH_SCREEN,
],
ProductType::PRODUCT_TYPE_ID_SMARTPHONE => [
Attribute::ATTRIBUTE_ID_QUALITY,
Attribute::ATTRIBUTE_ID_OPERATING_SYSTEM,
Attribute::ATTRIBUTE_ID_SCREEN_SIZE,
Attribute::ATTRIBUTE_ID_MAXIMUM_RESOLUTION,
Attribute::ATTRIBUTE_ID_MEMORY,
Attribute::ATTRIBUTE_ID_CPU_PHONE,
],
ProductType::PRODUCT_TYPE_ID_TABLET => [
Attribute::ATTRIBUTE_ID_QUALITY,
Attribute::ATTRIBUTE_ID_SCREEN_SIZE,
Attribute::ATTRIBUTE_ID_MAXIMUM_RESOLUTION,
Attribute::ATTRIBUTE_ID_MEMORY,
Attribute::ATTRIBUTE_ID_CPU_TABLET,
],
];
/**
* @param int $productType
*
* @return array
*/
public static function getFiltersForProductType(int $productType): array
{
return self::PRODUCT_TYPE_FILTERS[$productType] ?? [];
}
/**
* @var int
*
* @Column(name="type", type="integer")
*/
private $type;
/**
* @var Domain
*
* @ManyToOne(targetEntity="Domain")
* @JoinColumn(name="domain_id", referencedColumnName="id")
*/
private $domain;
/**
* @var CategoryPage|null
*
* @ManyToOne(targetEntity="CategoryPage", inversedBy="subCategories")
* @JoinColumn(name="parent_category_id", referencedColumnName="id", nullable=true)
*/
private $parentCategory;
/**
* @var ArrayCollection
*
* @ManyToMany(targetEntity="ProductType", inversedBy="categoryPages")
* @JoinTable(
* name="category_pages_product_types",
* joinColumns={
* @JoinColumn(name="category_page_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @JoinColumn(name="product_type_id", referencedColumnName="id")
* }
* )
* @OrderBy({"id" = "DESC"})
*/
private $productTypes;
/**
* @var ArrayCollection
*
* @ManyToMany(targetEntity="Product", inversedBy="categoryPages")
* @JoinTable(name="category_pages_products",
* joinColumns={
* @JoinColumn(name="category_page_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @JoinColumn(name="product_id", referencedColumnName="id")
* }
* )
* @OrderBy({"id" = "DESC"})
*/
private $products;
/**
* @var ArrayCollection
*
* @ManyToMany(targetEntity="Product", inversedBy="popularProductsCategoryPages")
* @JoinTable(name="category_pages_popular_products",
* joinColumns={
* @JoinColumn(name="category_page_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @JoinColumn(name="product_id", referencedColumnName="id")
* }
* )
* @OrderBy({"id" = "DESC"})
*/
private $popularProducts;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CategoryPage", mappedBy="parentCategory", orphanRemoval=true, cascade={"persist", "remove"})
* @OrderBy({"id" = "ASC"})
*/
private $subCategories;
/**
* @var ArrayCollection<int,PageMeta>
*
* @OneToMany(targetEntity="PageMeta", mappedBy="categoryPage", orphanRemoval=true, cascade={"persist", "remove"})
* @OrderBy({"id" = "ASC"})
**/
private $metas;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CategoryPageFilterAttribute", mappedBy="categoryPage", orphanRemoval=true, cascade={"persist", "remove"})
* @OrderBy({"delta" = "ASC"})
*/
private $filterAttributes;
/**
* @var ArrayCollection
*
* @ManyToMany(targetEntity="Vendor", inversedBy="categoryPages")
* @JoinTable(name="category_pages_vendors",
* joinColumns={
* @JoinColumn(name="category_page_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @JoinColumn(name="vendor_id", referencedColumnName="id")
* }
* )
* @OrderBy({"id" = "DESC"})
*/
private $vendors;
/**
* @var string
*
* @Column(name="badges", type="string")
*/
private $badges = '';
/**
* @var bool
*
* @Column(name="show_only_discounted", type="boolean")
*/
private $showOnlyDiscounted = false;
/**
* @var bool
*
* @Column(name="show_only_flash_sales", type="boolean")
*/
private $showOnlyFlashSales = false;
/**
* @var bool
*
* @Column(name="show_only_bazaar", type="boolean", options={"default": 0 })
*/
private $showOnlyBazaar = false;
/**
* @var bool
*
* @Column(name="include_bazaar", type="boolean", options={"default": 0 })
*/
private $includeBazaar = false;
/**
* @var ArrayCollection
*
* @OneToMany(targetEntity="CategoryPagesPriorityProducts", mappedBy="categoryPage")
*/
private $priorityProducts;
/**
* @var bool
*
* @Column(name="show_popular_products", type="boolean", options={"default": 1})
*/
private $showPopularProducts = true;
/**
* @var ArrayCollection
*
* @ManyToMany(targetEntity="ProductTag", inversedBy="categoryPages")
* @JoinTable(name="category_pages_product_tags",
* joinColumns={
* @JoinColumn(name="category_page_id", referencedColumnName="id", onDelete="CASCADE")
* },
* inverseJoinColumns={
* @JoinColumn(name="product_tag_id", referencedColumnName="id", onDelete="CASCADE")
* }
* )
* @OrderBy({"id" = "DESC"})
*/
private $productTags;
public function __construct()
{
parent::__construct();
$this->productTypes = new ArrayCollection();
$this->products = new ArrayCollection();
$this->metas = new ArrayCollection();
$this->filterAttributes = new ArrayCollection();
$this->productTags = new ArrayCollection();
}
/**
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* @param int $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return Domain
*/
public function getDomain()
{
return $this->domain;
}
/**
* @param Domain $domain
*/
public function setDomain($domain)
{
$this->domain = $domain;
}
public function getLanguage()
{
$this->getDomain()->getLanguage()->getCode();
}
/**
* @return CategoryPage|null
*/
public function getParentCategory()
{
return $this->parentCategory;
}
/**
* @param CategoryPage|null $parentCategory
*
* @return void
*/
public function setParentCategory($parentCategory): void
{
$this->parentCategory = $parentCategory;
}
/**
* @return ArrayCollection
*/
public function getProductTypes()
{
return $this->productTypes;
}
/**
* @param ArrayCollection $productTypes
*/
public function setProductTypes($productTypes)
{
$this->productTypes = $productTypes;
}
/**
* Add ProductType
*
* @param ProductType $productType
*/
public function addProductType($productType)
{
if (!$this->productTypes->contains($productType)) {
$this->productTypes->add($productType);
}
}
/**
* Remove ProductType
*
* @param ProductType $productType
*/
public function removeProductType($productType)
{
$this->productTypes->removeElement($productType);
}
/**
* @return ArrayCollection
*/
public function getProducts()
{
return $this->products;
}
/**
* @param ArrayCollection $products
*/
public function setProducts($products)
{
$this->products = $products;
}
/**
* @return ArrayCollection
*/
public function getSubCategories()
{
return $this->subCategories;
}
/**
* Add Product
*
* @param Product $product
*/
public function addProduct($product)
{
if (!$this->products->contains($product)) {
$this->products->add($product);
}
}
/**
* Remove Product
*
* @param Product $product
*/
public function removeProduct($product)
{
$this->products->removeElement($product);
}
/**
* Get Popular Product
*
* @return ArrayCollection
*/
public function getPopularProducts()
{
return $this->popularProducts;
}
/**
* Add Popular Product
*
* @param Product $product
*/
public function addPopularProduct(Product $product): void
{
if (!$this->popularProducts->contains($product)) {
$this->popularProducts->add($product);
}
}
/**
* Remove Popular Product
*
* @param Product $product
*/
public function removePopularProduct(Product $product): void
{
$this->popularProducts->removeElement($product);
}
/**
* @return ArrayCollection<int,PageMeta>
*/
public function getMetas()
{
return $this->metas;
}
/**
* @param Language $language
* @return null|PageMeta
*/
public function getMetaByLanguage(Language $language)
{
foreach ($this->getMetas() as $meta) {
if ($meta->getLanguage()->getCode() == $language->getCode()) {
return $meta;
}
}
return null;
}
/**
* @param string $code
* @return null|PageMeta
*/
public function getMetaByCode($code)
{
foreach ($this->getMetas() as $meta) {
if ($meta->getLanguage()->getCode() == $code) {
return $meta;
}
}
return null;
}
/**
* @return ArrayCollection
*/
public function getFilterAttributes()
{
return $this->filterAttributes;
}
/**
* @param ArrayCollection $filterAttribute
*/
public function setFilterAttributes($filterAttribute)
{
$this->filterAttributes = $filterAttribute;
}
/**
* Add Filter Attribute
*
* @param CategoryPageFilterAttribute $filterAttribute
*/
public function addFilterAttribute(CategoryPageFilterAttribute $filterAttribute)
{
if (!$this->filterAttributes->contains($filterAttribute)) {
$this->filterAttributes->add($filterAttribute);
}
}
/**
* Remove Attribute
*
* @param Attribute $filterAttribute
*/
public function removeFilterAttribute($filterAttribute)
{
foreach ($this->filterAttributes as $item) {
if ((int)$filterAttribute->getId() == (int)$item->getAttribute()->getId()) {
$this->filterAttributes->removeElement($item);
break;
}
}
}
public function clearFilterAttribute()
{
$this->filterAttributes = new ArrayCollection();
}
/**
* @return ArrayCollection
*/
public function getVendors()
{
return $this->vendors;
}
/**
* @param ArrayCollection $vendors
*/
public function setVendors($vendors)
{
$this->vendors = $vendors;
}
/**
* Add Vendor
*
* @param Vendor $vendor
*/
public function addVendor($vendor)
{
if (!$this->vendors->contains($vendor)) {
$this->vendors->add($vendor);
}
}
/**
* Remove Vendor
*
* @param Vendor $vendor
*/
public function removeVendor($vendor)
{
$this->vendors->removeElement($vendor);
}
/**
* @return string
*/
public function getBadges()
{
return $this->badges;
}
/**
* @param string $badges
*/
public function setBadges($badges)
{
$this->badges = $badges;
}
/**
* @return bool
*/
public function isShowOnlyDiscounted()
{
return $this->showOnlyDiscounted;
}
/**
* @param bool $showOnlyDiscounted
*/
public function setShowOnlyDiscounted($showOnlyDiscounted)
{
$this->showOnlyDiscounted = $showOnlyDiscounted;
}
/**
* @return bool
*/
public function isShowOnlyFlashSales()
{
return $this->showOnlyFlashSales;
}
/**
* @param bool $showOnlyFlashSales
*/
public function setShowOnlyFlashSales($showOnlyFlashSales)
{
$this->showOnlyFlashSales = $showOnlyFlashSales;
}
/**
* @return bool
*/
public function isShowOnlyBazaar(): bool
{
return $this->showOnlyBazaar;
}
/**
* @param bool $showOnlyBazaar
*/
public function setShowOnlyBazaar(bool $showOnlyBazaar): void
{
$this->showOnlyBazaar = $showOnlyBazaar;
}
/**
* @return bool
*/
public function isIncludeBazaar(): bool
{
return $this->includeBazaar;
}
/**
* @param bool $includeBazaar
*/
public function setIncludeBazaar(bool $includeBazaar): void
{
$this->includeBazaar = $includeBazaar;
}
/**
* @return ArrayCollection
*/
public function getPriorityProducts()
{
return $this->priorityProducts;
}
/**
* @return bool
*/
public function isShowPopularProducts(): bool
{
return $this->showPopularProducts;
}
/**
* @param bool $showPopularProducts
* @return void
*/
public function setShowPopularProducts(bool $showPopularProducts): void
{
$this->showPopularProducts = $showPopularProducts;
}
/**
* @return ArrayCollection
*/
public function getProductTags()
{
return $this->productTags;
}
/**
* Add ProductTag
*
* @param ProductTag $productTag
*/
public function addProductTag(ProductTag $productTag): void
{
if (!$this->productTags->contains($productTag)) {
$this->productTags->add($productTag);
}
}
/**
* Remove ProductTag
*
* @param ProductTag $productTag
*/
public function removeProductTag(ProductTag $productTag): void
{
$this->productTags->removeElement($productTag);
}
}