<?php
namespace App\AtechNet\CoreBundle\Controller;
use App\AtechNet\CoreBundle\Entity\Basket;
use App\AtechNet\CoreBundle\Entity\CategoryPage;
use App\AtechNet\CoreBundle\Entity\Customer;
use App\AtechNet\CoreBundle\Entity\Domain;
use App\AtechNet\CoreBundle\Entity\DomainNavigation;
use App\AtechNet\CoreBundle\Entity\Language;
use App\AtechNet\CoreBundle\Entity\Nanobar;
use App\AtechNet\CoreBundle\Entity\Order;
use App\AtechNet\CoreBundle\Entity\Product;
use App\AtechNet\CoreBundle\Entity\ProductType;
use App\AtechNet\CoreBundle\Entity\SeoUrl;
use App\AtechNet\CoreBundle\Entity\User;
use App\AtechNet\CoreBundle\Helper\ActiveCampaignConnect;
use App\AtechNet\CoreBundle\Helper\Billingo;
use App\AtechNet\CoreBundle\Helper\DigitalOceanSpaces;
use App\AtechNet\CoreBundle\Helper\Furbify\Cetelem;
use App\AtechNet\CoreBundle\Helper\Furbify\GoPayHelper;
use App\AtechNet\CoreBundle\Helper\Furbify\Image;
use App\AtechNet\CoreBundle\Helper\Furbify\Login;
use App\AtechNet\CoreBundle\Helper\Furbify\Module;
use App\AtechNet\CoreBundle\Helper\Furbify\MultiStore;
use App\AtechNet\CoreBundle\Helper\Furbify\OrderHelper;
use App\AtechNet\CoreBundle\Helper\Furbify\PayPal;
use App\AtechNet\CoreBundle\Helper\Furbify\ProductHelper;
use App\AtechNet\CoreBundle\Helper\Furbify\SeoUrlHelper;
use App\AtechNet\CoreBundle\Helper\Furbify\SimplePayHelper;
use App\AtechNet\CoreBundle\Helper\Furbify\SocialShareImageHelper;
use App\AtechNet\CoreBundle\Helper\Instacash;
use App\AtechNet\CoreBundle\Helper\Klarna;
use App\AtechNet\CoreBundle\Helper\KlaviyoConnect;
use App\AtechNet\CoreBundle\Helper\Milpay;
use App\AtechNet\CoreBundle\Helper\Packeta;
use App\AtechNet\CoreBundle\Helper\PastPay;
use App\AtechNet\CoreBundle\Helper\SquarePay;
use App\AtechNet\CoreBundle\Service\Furbify\BazaarService;
use App\AtechNet\CoreBundle\Service\HistoricalEuroRate;
use App\AtechNet\CoreBundle\Translation\DatabaseTranslator;
use Doctrine\ORM\EntityManager;
use Doctrine\Persistence\ManagerRegistry;
use Psr\Cache\CacheItemPoolInterface;
use Psr\SimpleCache\InvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController as SymfonyAbstractController;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;
abstract class AbstractController extends SymfonyAbstractController
{
public const CUSTOMER_TYPE_RETAIL = 1;
public const CUSTOMER_TYPE_WHOLESALE = 2;
public const CACHE_LIFETIME_15_MINUTES = 900;
public const CACHE_LIFETIME_30_MINUTES = 1800;
public const CACHE_LIFETIME_1_HOUR = 3600;
public const CACHE_LIFETIME_4_HOUR = 14400;
public const CACHE_LIFTETIME_6_HOURS = 21600;
public const CACHE_LIFETIME_12_HOURS = 43200;
public const CACHE_LIFETIME_1_DAY = 86400;
public const CACHE_LIFETIME_3_DAYS = 259200;
public const CACHE_LIFETIME_7_DAYS = 604800;
public const CACHE_LIFETIME_1_YEAR = 31536000;
// Warranty types
public const WARRANTY_TYPE_DEFAULT = 'default';
public const WARRANTY_TYPE_PRODUCT_TYPE = 'byProductTyp';
public const WARRANTY_TYPE_NOTEBOOK_BATTERY = 'byBatteryType';
public const WARRANTY_DEFAULT_ARRAY = [
'year' => 2,
'priceWarrantyDay' => 30,
];
public const WARRANTY_3_YEARS_60_DAYS_ARRAY = [
'year' => 3,
'priceWarrantyDay' => 60,
];
public const WARRANTY_NOTEBOOK_BATTERY_ARRAY = [
'year' => 0.5,
'priceWarrantyDay' => 30,
];
private $storeSwitcher;
public function __construct(
ManagerRegistry $doctrine,
TranslatorInterface $translator,
UrlGeneratorInterface $router,
MailerInterface $mailer,
RequestStack $requestStack,
Security $security,
HistoricalEuroRate $historicalEuroRate,
KernelInterface $kernel,
Environment $twig,
protected CacheItemPoolInterface $cache,
private BazaarService $bazaarService
) {
$this->doctrine = $doctrine;
$this->translator = $translator;
$this->router = $router;
$this->mailer = $mailer;
$this->requestStack = $requestStack;
$this->security = $security;
$this->historicalEuroRate = $historicalEuroRate;
$this->kernel = $kernel;
$this->twig = $twig;
}
/**
* @return EntityManager
*/
public function getEntityManager(string $connection = 'default'): EntityManager
{
return $this->doctrine->getManager($connection);
}
/**
* @return string[]
*/
public static function getWarrantyTypesByDomains(): array
{
return [
Domain::DOMAIN_ID_RT_SK => self::WARRANTY_TYPE_DEFAULT,
Domain::DOMAIN_ID_WS_SK => self::WARRANTY_TYPE_DEFAULT,
Domain::DOMAIN_ID_RT_HU => self::WARRANTY_TYPE_DEFAULT,
Domain::DOMAIN_ID_WS_HU => self::WARRANTY_TYPE_DEFAULT,
Domain::DOMAIN_ID_RT_EU => self::WARRANTY_TYPE_DEFAULT,
Domain::DOMAIN_ID_WS_CZ => self::WARRANTY_TYPE_DEFAULT,
Domain::DOMAIN_ID_RT_CZ => self::WARRANTY_TYPE_DEFAULT,
Domain::DOMAIN_ID_WS_EU => self::WARRANTY_TYPE_DEFAULT,
];
}
/**
* @return array
*/
public static function getWarranty(): array
{
return [
Domain::DOMAIN_ID_RT_SK => [
self::WARRANTY_TYPE_DEFAULT => self::WARRANTY_DEFAULT_ARRAY,
self::WARRANTY_TYPE_NOTEBOOK_BATTERY => self::WARRANTY_NOTEBOOK_BATTERY_ARRAY,
],
Domain::DOMAIN_ID_WS_SK => [
self::WARRANTY_TYPE_DEFAULT => self::WARRANTY_DEFAULT_ARRAY,
self::WARRANTY_TYPE_NOTEBOOK_BATTERY => self::WARRANTY_NOTEBOOK_BATTERY_ARRAY,
],
Domain::DOMAIN_ID_RT_HU => [
self::WARRANTY_TYPE_DEFAULT => self::WARRANTY_DEFAULT_ARRAY,
self::WARRANTY_TYPE_NOTEBOOK_BATTERY => self::WARRANTY_NOTEBOOK_BATTERY_ARRAY,
],
Domain::DOMAIN_ID_WS_HU => [
self::WARRANTY_TYPE_DEFAULT => self::WARRANTY_DEFAULT_ARRAY,
self::WARRANTY_TYPE_NOTEBOOK_BATTERY => self::WARRANTY_NOTEBOOK_BATTERY_ARRAY,
],
Domain::DOMAIN_ID_WS_CZ => [
self::WARRANTY_TYPE_DEFAULT => self::WARRANTY_DEFAULT_ARRAY,
self::WARRANTY_TYPE_NOTEBOOK_BATTERY => self::WARRANTY_NOTEBOOK_BATTERY_ARRAY,
],
Domain::DOMAIN_ID_WS_EU => [
self::WARRANTY_TYPE_DEFAULT => self::WARRANTY_DEFAULT_ARRAY,
self::WARRANTY_TYPE_NOTEBOOK_BATTERY => self::WARRANTY_NOTEBOOK_BATTERY_ARRAY,
],
Domain::DOMAIN_ID_RT_CZ => [
self::WARRANTY_TYPE_DEFAULT => self::WARRANTY_DEFAULT_ARRAY,
self::WARRANTY_TYPE_NOTEBOOK_BATTERY => self::WARRANTY_NOTEBOOK_BATTERY_ARRAY,
],
Domain::DOMAIN_ID_RT_EU => [
self::WARRANTY_TYPE_DEFAULT => self::WARRANTY_DEFAULT_ARRAY,
self::WARRANTY_TYPE_NOTEBOOK_BATTERY => self::WARRANTY_NOTEBOOK_BATTERY_ARRAY,
],
];
}
/**
* @param int $domainId
* @param int $productTypeId
* @return mixed
*/
protected function getWarrantyForProductType(int $domainId, int $productTypeId)
{
$warrantyType = self::WARRANTY_TYPE_DEFAULT;
if ($productTypeId == ProductType::PRODUCT_TYPE_ID_NOTEBOOK_BATTERY) {
$warrantyType = self::WARRANTY_TYPE_NOTEBOOK_BATTERY;
}
if (
!empty(self::getWarranty()[$domainId][self::getWarrantyTypesByDomains()[$domainId]]['typeIds']) &&
in_array($productTypeId, self::getWarranty()[$domainId][self::getWarrantyTypesByDomains()[$domainId]]['typeIds'])
) {
$warrantyType = self::WARRANTY_TYPE_PRODUCT_TYPE;
}
return self::getWarranty()[$domainId][$warrantyType];
}
/**
* @param int $domainId
* @param string $valueName
* @return int|mixed
*
* header, footer, login-page, ..., texts
*/
protected function getWarrantyForNonProductText(int $domainId, string $valueName = 'year')
{
$warrantyObjectForDomain = self::getWarranty()[$domainId];
unset($warrantyObjectForDomain[self::WARRANTY_TYPE_NOTEBOOK_BATTERY]);
$warrantyYear = 99;
foreach ($warrantyObjectForDomain as $key => $value) {
if ($warrantyYear > $value[$valueName]) {
$warrantyYear = $value[$valueName];
}
}
return $warrantyYear;
}
/**
* @param Request $request
* @return string The rendered view
* @throws \Exception
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function getHeader(Request $request)
{
// Entity Manager
$entityManager = $this->getEntityManager();
// Connection
$connection = $entityManager->getConnection();
// Route
$route = $request->attributes->get('_route');
$module = $this->getModuleHelper($request);
$data = [];
if (in_array($route, ['cart_show', 'cart_show_locale', 'checkout_customer', 'checkout_customer_locale', 'checkout_shipping_and_payment', 'checkout_shipping_and_payment_locale', 'checkout_address', 'checkout_address_locale', 'checkout_review', 'checkout_review_locale'])) {
$data['mode'] = 'minimal';
} else {
$data['mode'] = 'standard';
$data['menu'] = $this->getMenu($request);
}
$multiStore = $this->getMultiStoreHelper($request);
$defaultLocale = $multiStore->getDefaultLocale();
$domain = $multiStore->getDomain();
$domainType = $domain->getType();
if ( $request->getSession()->get('isBazaarPage') === true ) {
$data['headerPageList'] = $this->bazaarService->getHeaderPageList($domain, $this->url($request));
} else {
$data['headerPageList'] = $this->getHeaderPageList($domain, $this->url($request));
}
$data['currency'] = $domain->getCurrency();
$data['precision'] = $domain->getPricePrecision();
$data['cart'] = $module->widgetCart();
$contactInfos = $this->getContactInfos();
$data['phone_support'] = $contactInfos['phone.webshop.' . $defaultLocale . '.' . $domainType];
$data['phone_order'] = $contactInfos['phone.webshop.' . $defaultLocale . '.' . $domainType];
$data['logo_country_suffix'] = '';
if (in_array($defaultLocale, ['sk', 'hu', 'cz'])) {
$data['logo_country_suffix'] = '-' . $defaultLocale;
}
// Search
if ($request->get('fs')) {
$data['filterSearch'] = $request->get('fs');
} else {
$data['filterSearch'] = '';
}
$data['cartTotal'] = 0;
$data['cartItemsCount'] = 0;
$data['customerType'] = $this->getCustomerTypeString($request);
$session = $request->getSession();
$loggedInCustomerId = $session->get('customerId');
$data['isLoggedIn'] = !is_null($loggedInCustomerId) && is_numeric($loggedInCustomerId);
$data['customer'] = $data['isLoggedIn'] ? $entityManager->getRepository(Customer::class)->findOneById($loggedInCustomerId) : null;
$data['nanobars'] = $this->getNanobars($domain, $defaultLocale);
$data['warrantyYear'] = $this->getWarrantyForNonProductText($domain->getId());
//-> Store & Language Switcher
// Environment
$environment = $this->getEnvironment();
// Stores
$this->storeSwitcher = [
0 => [
'url' => ($environment == 'dev' ? 'http://furbify.dev.sk' : 'https://www.furbify.sk'),
'source' => 'furbify.sk',
'title' => 'Furbify.sk',
'icon' => 'sk',
'primary' => false,
'language' => [
'sk' => 'Slovenčina',
'hu' => 'Magyar',
'en' => 'English',
],
],
1 => [
'url' => ($environment == 'dev' ? 'http://furbify.dev.hu' : 'https://www.furbify.hu'),
'source' => 'furbify.hu',
'title' => 'Furbify.hu',
'icon' => 'hu',
'primary' => false,
'language' => [
'hu' => 'Magyar',
'en' => 'English',
],
],
2 => [
'url' => ($environment == 'dev' ? 'http://furbify.dev.cz' : 'https://www.furbify.cz'),
'source' => 'furbify.cz',
'title' => 'Furbify.cz',
'icon' => 'cz',
'primary' => false,
'language' => [
'cz' => 'Čeština',
'sk' => 'Slovenčina',
'en' => 'English',
],
],
3 => [
'url' => ($environment == 'dev' ? 'http://furbify.dev.eu' : 'https://www.furbify.eu'),
'source' => 'furbify.eu',
'title' => 'Furbify.eu',
'icon' => 'eu',
'primary' => false,
'language' => [
'en' => 'English',
'sk' => 'Slovenčina',
'hu' => 'Magyar',
'cz' => 'Čeština',
],
],
];
if ($domain->getId() == Domain::DOMAIN_ID_RT_EU) {
$locales = [
'de' => 'furbify.de',
'fr' => 'furbify.fr',
'it' => 'furbify.it',
'es' => 'furbify.es',
'nl' => 'furbify.nl',
'ro' => 'furbify.ro',
'se' => 'furbify.se',
'hr' => 'furbify.hr',
'si' => 'furbify.si',
#'dk' => 'furbify.dk',
'ie' => 'furbify.ie',
];
foreach ($locales as $code => $domainName) {
$this->storeSwitcher[] = [
'url' => "https://www.$domainName/",
'source' => $domainName,
'title' => ucfirst($domainName),
'icon' => $code,
'primary' => false,
'unas' => true,
];
}
}
// Slug
$slug = $request->get('slug');
if (!empty($slug)) {
// URL Path
$urlPath = [
Domain::DOMAIN_ID_RT_SK => [],
Domain::DOMAIN_ID_RT_HU => [],
Domain::DOMAIN_ID_RT_CZ => [],
Domain::DOMAIN_ID_RT_EU => [],
];
// Parts of Slug
$parts = explode('/', $slug);
// Remove any empty arrays from trailing
if (mb_strlen(end($parts)) == 0) {
array_pop($parts);
}
// Start with the low-level part
$parts = array_reverse($parts);
// Language ID
$languageId = $multiStore->getDefaultLanguageId();
// Domain
$domainId = $domain->getId();
if (in_array($domainId, MultiStore::getWholesaleDomainIDs())) {
switch ($domainId) {
case Domain::DOMAIN_ID_WS_SK:
$domainId = Domain::DOMAIN_ID_RT_SK;
break;
case Domain::DOMAIN_ID_WS_HU:
$domainId = Domain::DOMAIN_ID_RT_HU;
break;
case Domain::DOMAIN_ID_WS_CZ:
$domainId = Domain::DOMAIN_ID_RT_CZ;
break;
case Domain::DOMAIN_ID_WS_EU:
$domainId = Domain::DOMAIN_ID_RT_EU;
break;
}
}
// Get entities by parts of slug
foreach ($parts as $part) {
// Seo URL
$seoUrl = $entityManager->getRepository(SeoUrl::class)->findOneBy([
'keyword' => $part,
'language' => $languageId,
'archived' => false,
'domain' => [$domainId, null],
]);
if ($seoUrl) {
// Query
$query = explode('=', $seoUrl->getQuery());
// Product
if ($query[0] == 'product_id') {
// Product ID
$productId = (int)$query[1];
// Product
$product = $entityManager->getRepository(Product::class)->findOneById($productId);
if ($product) {
// Meta
foreach ($product->getMetas() as $meta) {
// Needle Domain ID
$needleDomainId = $meta->getDomain()->getId();
if ($meta->isActive() && isset($urlPath[$needleDomainId])) {
$productSeoUrl = $connection->fetchAssociative("SELECT `keyword` FROM seo_url WHERE archived = '0' AND domain_id IS NULL AND language_id = '" . $multiStore->getLanguageIdByDomainId((int)$needleDomainId) . "' AND `query` = 'product_id=" . (int)$productId . "'");
if (!empty($productSeoUrl['keyword']) && isset($urlPath[(int)$needleDomainId])) {
$urlPath[(int)$needleDomainId][] = $productSeoUrl['keyword'];
}
}
}
}
}
// Category
elseif ($query[0] == 'category_id') {
// Category ID
$categoryId = (int)$query[1];
// Category
$category = $entityManager->getRepository(CategoryPage::class)->findOneById($categoryId);
if ($category) {
if ($category->getType() == CategoryPage::CATEGORY_TYPE_PRODUCT) {
// Haystack Categories
$haystackCategories = $entityManager->getRepository(CategoryPage::class)->findBy([
'type' => CategoryPage::CATEGORY_TYPE_PRODUCT,
'published' => 1,
'showOnlyDiscounted' => $category->isShowOnlyDiscounted(),
'showOnlyFlashSales' => $category->isShowOnlyFlashSales(),
'showOnlyBazaar' => $category->isShowOnlyBazaar(),
'includeBazaar' => $category->isIncludeBazaar(),
], [
'updated' => 'DESC',
]);
// Use Cache
if (!empty($haystackCategories[0])) {
// Updated
$updated = $haystackCategories[0]->getUpdated();
// Cache Key
$cacheKey = 'store.switcher.v3.haystack.categories.' . $categoryId . '.' . $domainId . '.' . $updated->getTimestamp();
$cacheItem = $this->cache->getItem($cacheKey);
if ($cacheItem->isHit()) {
$cacheUrlPath = $cacheItem->get();
foreach ($cacheUrlPath as $cacheDomainId => $cachePath) {
$urlPath[(int)$cacheDomainId][] = $cachePath;
}
}
}
if (empty($cacheUrlPath)) {
$cacheUrlPath = [];
foreach ($haystackCategories as $needleCategory) {
// Product Types
$productTypes = $category->getProductTypes();
$needleProductTypes = $needleCategory->getProductTypes();
// Presumably, the needle category match with category according to product type
if ($productTypes->count() > 0 && $productTypes->count() == $needleProductTypes->count()) {
// Skip it if the needle category does not contains all product types of the category
foreach ($productTypes as $productType) {
if (!$needleProductTypes->contains($productType)) {
continue 2;
}
}
} // Presumably there is no match, so we skip it
elseif ($productTypes->count() !== $needleProductTypes->count()) {
continue;
}
// Vendors
$vendors = $category->getVendors();
$needleVendors = $needleCategory->getVendors();
// Presumably, the needle category match with category according to vendor
if ($vendors->count() > 0 && $vendors->count() == $needleVendors->count()) {
// Skip it if the needle category does not contains all vendors of the category
foreach ($vendors as $vendor) {
if (!$needleVendors->contains($vendor)) {
continue 2;
}
}
} // Presumably there is no match, so we skip it
elseif ($vendors->count() !== $needleVendors->count()) {
continue;
}
// Products
$products = $category->getProducts();
$needleProducts = $needleCategory->getProducts();
// Presumably, the needle category match with category according to product
if ($products->count() > 0 && $products->count() == $needleProducts->count()) {
// Skip it if the needle category does not contains all products of the category
foreach ($products as $product) {
if (!$needleProducts->contains($product)) {
continue 2;
}
}
} // Presumably there is no match, so we skip it
elseif ($products->count() !== $needleProducts->count()) {
continue;
}
// Badges
$badges = $category->getBadges();
$needleBadges = $needleCategory->getBadges();
// Reset
if ($badges == '[]') {
$badges = '';
}
if ($needleBadges == '[]') {
$needleBadges = '';
}
// Presumably, the needle category match with category according to badge
if (!empty($badges) && $badges == $needleBadges) {
$badges = json_decode($badges, true);
$needleBadges = json_decode($needleBadges, true);
// Skip it if the needle category does not contains all badges of the category
foreach ($badges as $badge) {
if (!in_array($badge, $needleBadges)) {
continue 2;
}
}
} // Presumably there is no match, so we skip it
elseif ($badges !== $needleBadges) {
continue;
}
// Domain Id
$needleDomainId = $needleCategory->getDomain()->getId();
// Presumably the category match with the needle category
// Therefore we query the seo keyword of the needle category
$categorySeoUrl = $connection->fetchAssociative("SELECT `keyword` FROM seo_url WHERE archived = '0' AND domain_id = '" . (int)$needleDomainId . "' AND language_id = '" . $multiStore->getLanguageIdByDomainId((int)$needleDomainId) . "' AND `query` = 'category_id=" . (int)$needleCategory->getId() . "'");
if (!empty($categorySeoUrl['keyword']) && isset($urlPath[(int)$needleDomainId])) {
$urlPath[(int)$needleDomainId][] = $categorySeoUrl['keyword'];
$cacheUrlPath[(int)$needleDomainId] = $categorySeoUrl['keyword'];
}
}
if (isset($cacheKey)) {
$cacheItem->set($cacheUrlPath);
$cacheItem->expiresAfter(self::CACHE_LIFETIME_7_DAYS);
$this->cache->save($cacheItem);
}
unset($cacheKey, $cacheUrlPath);
}
}
}
}
}
}
// Validate found path & add to store switcher
foreach ($urlPath as $domainId => $path) {
if (!empty($path) && count($path) == count($parts)) {
// Build Path
$path = array_reverse($path);
$path = implode('/', $path);
switch ($domainId) {
case Domain::DOMAIN_ID_RT_SK:
$this->storeSwitcher[0]['url'] .= '/' . $path;
break;
case Domain::DOMAIN_ID_RT_HU:
$this->storeSwitcher[1]['url'] .= '/' . $path;
break;
case Domain::DOMAIN_ID_RT_CZ:
$this->storeSwitcher[2]['url'] .= '/' . $path;
break;
case Domain::DOMAIN_ID_RT_EU:
$this->storeSwitcher[3]['url'] .= '/' . $path;
break;
}
}
}
}
// Determine primary domain
switch ($domain->getId()) {
// Slovakia -> Hungary, Czech Republic, EU
case Domain::DOMAIN_ID_RT_SK:
case Domain::DOMAIN_ID_WS_SK:
$this->storeSwitcher[0]['primary'] = true;
break;
// Hungary -> Slovakia, Czech Republic, EU
case Domain::DOMAIN_ID_RT_HU:
case Domain::DOMAIN_ID_WS_HU:
$this->storeSwitcher[1]['primary'] = true;
break;
// Czech Republic -> Slovakia, Hungary, EU
case Domain::DOMAIN_ID_RT_CZ:
case Domain::DOMAIN_ID_WS_CZ:
$this->storeSwitcher[2]['primary'] = true;
break;
// EU -> Slovakia, Hungary, Czech Republic
case Domain::DOMAIN_ID_RT_EU:
case Domain::DOMAIN_ID_WS_EU:
$this->storeSwitcher[3]['primary'] = true;
break;
}
$data['stores'] = $this->storeSwitcher;
//<- Store & Language Switcher
// Bazaar
$data['isBazaarPage'] = $request->getSession()->get('isBazaarPage');
return $this->renderView('AtechNetCoreBundle/Common/header.html.twig', $data);
}
/**
* @var Domain $domain
* @var SeoUrlHelper $seoUrl
* @return array
*/
protected function getHeaderPageList(Domain $domain, SeoUrlHelper $seoUrl): array
{
switch ($domain->getLanguage()->getId()) {
case Language::LANGUAGE_ID_HU:
return [
[
'link' => $seoUrl->link('page', [
'static_id' => 20,
]),
'title' => 'Rólunk',
],
[
'link' => $seoUrl->link('page', [
'static_id' => 21,
]),
'title' => 'Felújítási folyamat',
],
[
'link' => $this->generateUrl('review_list_hu'),
'title' => 'Referenciák',
],
[
'link' => $seoUrl->link('page', [
'static_id' => 26,
]),
'title' => 'GYIK',
],
/*[
'link' => $seoUrl->link('page', ['static_id' => 40]),
'title' => 'Garancia'
],*/
[
'link' => $seoUrl->link('page', [
'static_id' => 202,
]),
'title' => 'Reklamáció és visszaküldés',
],
[
'link' => $this->generateUrl('blog_main'),
'title' => 'Blog',
],
];
case Language::LANGUAGE_ID_SK:
return [
[
'link' => $seoUrl->link('page', [
'static_id' => 50,
]),
'title' => 'O nás',
],
[
'link' => $seoUrl->link('page', [
'static_id' => 4,
]),
'title' => 'Čo je repasovaný počítač?',
],
[
'link' => $this->generateUrl('review_list_sk'),
'title' => 'Hodnotenia zákazníkov',
],
[
'link' => $seoUrl->link('page', [
'static_id' => 10,
]),
'title' => 'FAQ',
],
/*[
'link' => $seoUrl->link('page', ['static_id' => 41]),
'title' => 'Garancia'
],*/
[
'link' => $seoUrl->link('page', [
'static_id' => 203,
]),
'title' => 'Vrátenie tovaru a reklamácie',
],
[
'link' => $this->generateUrl('blog_main'),
'title' => 'Blog',
],
];
case Language::LANGUAGE_ID_CZ:
return [
[
'link' => $seoUrl->link('page', [
'static_id' => 74,
]),
'title' => 'O nás',
],
[
'link' => $seoUrl->link('page', [
'static_id' => 54,
]),
'title' => 'Čo sú renovované zariadenia?',
],
[
'link' => $this->generateUrl('review_list_cz'),
'title' => 'Hodnocení zákazníků',
],
[
'link' => $seoUrl->link('page', [
'static_id' => 59,
]),
'title' => 'FAQ',
],
/*[
'link' => $seoUrl->link('page', ['static_id' => 69]),
'title' => 'Garance'
],*/
[
'link' => $seoUrl->link('page', [
'static_id' => 204,
]),
'title' => 'Odstoupení od smlouvy a reklamace',
],
[
'link' => $this->generateUrl('blog_main'),
'title' => 'Blog',
],
];
case Language::LANGUAGE_ID_EN:
return [
[
'link' => $seoUrl->link('page', [
'static_id' => 114,
]),
'title' => 'We Are Furbify',
],
/*[
'link' => $seoUrl->link('page', ['static_id' => 96]),
'title' => 'What is a refurbished computer?'
],*/
[
'link' => $seoUrl->link('page', [
'static_id' => 99,
]),
'title' => 'FAQ',
],
[
'link' => $seoUrl->link('page', [
'static_id' => 154,
]),
'title' => 'Shipping, Returns & Claims',
],
[
'link' => $this->generateUrl('blog_main'),
'title' => 'Blog',
],
];
}
return [];
}
/**
* @param Request $request
* @return string
* @throws InvalidArgumentException
*/
public function getFooter(Request $request): string
{
$data = [];
$locale = $request->getLocale();
$multiStore = $this->getMultiStoreHelper($request);
$domain = $multiStore->getDomain();
$domainId = $domain->getId();
$defaultLocale = $multiStore->getDefaultLocale();
$route = $request->attributes->get('_route');
$data['salesManager'] = null;
$data['warrantyYear'] = $this->getWarrantyForNonProductText($domainId);
if ($domain->getType() == 'wholesale') {
// default salesManager
$data['salesManager'] = $domain->getDefaultSalesManager()->getFirstName();
}
if (in_array($route, ['cart_show', 'cart_show_locale', 'checkout_customer', 'checkout_customer_locale', 'checkout_shipping_and_payment', 'checkout_shipping_and_payment_locale', 'checkout_address', 'checkout_address_locale', 'checkout_review', 'checkout_review_locale'])) {
$data['mode'] = 'minimal';
} else {
$data['mode'] = 'standard';
}
$footerCacheKey = 'footer.' . $domain->getId() . '.v4' . $defaultLocale . '.' . $locale . '.' . $data['mode'];
$footerCacheItem = $this->cache->getItem($footerCacheKey);
if ($footerCacheItem->isHit()) {
$data = $footerCacheItem->get();
} else {
$data['locale'] = $locale;
$data['year'] = (new \DateTime())->format('Y');
$languageId = $multiStore->getDefaultLanguageId();
$seoUrl = $this->url($request);
$contactInfos = $this->getContactInfos();
$data['phone_support'] = $contactInfos['phone.webshop.' . $defaultLocale . '.' . $domain->getType()];
$data['footerMenu'] = [];
$translator = $this->getTranslator();
$skippingTitles = [
$this->getTranslator()->trans('Free Norton subscription'),
$this->getTranslator()->trans('Furbify installment'),
];
foreach ($this->getFooterMenuPagesList()[$languageId] as $key => $menu) {
$data['footerMenu'][$key]['title'] = $menu['title'];
foreach ($menu['items'] as $page) {
$filterLink = array_values($page)[0]['filter'] ?? '';
$pageTitle = array_values($page)[0]['title'];
$pageId = array_key_first($page);
//WS DOMAINS SKIP NORTON AND BUY NOW PAY LATER
if (in_array($domainId, MultiStore::getWholesaleDomainIDs())
&& in_array($pageTitle, $skippingTitles) ) {
continue;
}
if (str_contains($pageId, '_')) {
$categoryPageId = explode('_', $pageId)[1];
$categoryPage = $this->getEntityManager()->find(CategoryPage::class, $categoryPageId);
if (
in_array($domainId, MultiStore::getRetailDomainIDs())
&& $categoryPage?->isShowOnlyBazaar()
) {
continue;
}
}
$data['footerMenu'][$key]['items'][] = [
'title' => $pageTitle,
'href' =>
$menu['module'] == 'category'
?
$seoUrl->link('category', [
'path' => $pageId,
])
:
(is_numeric($pageId)
?
$seoUrl->link($menu['module'], [
$menu['module'] == 'page' ? 'static_id' : $menu['module'] => $pageId,
])
:
$this->generateUrl($pageId)
),
'filterLink' => $filterLink,
];
}
}
$data['facebook_link'] = $languageId == Language::LANGUAGE_ID_HU ? 'https://www.facebook.com/furbify.hu' : 'https://www.facebook.com/furbify.sk';
$data['instagram_link'] = $languageId == Language::LANGUAGE_ID_HU ? 'https://www.instagram.com/furbify.hu' : 'https://www.instagram.com/furbify.sk';
$data['footerMinimalMenu'] = [];
foreach ($this->getCheckoutFooterMenuPagesList()[$languageId] as $pageId => $pageTitle) {
$page['title'] = $pageTitle;
$page['link'] = $seoUrl->link('page', [
'static_id' => $pageId,
]);
$data['footerMinimalMenu'][] = $page;
}
if ( $request->getSession()->get('isBazaarPage') === true ) {
$data['headerPageList'] = $this->bazaarService->getHeaderPageList($domain, $this->url($request));
} else {
$data['headerPageList'] = $this->getHeaderPageList($domain, $this->url($request));
}
$footerCacheItem->set($data);
$footerCacheItem->expiresAfter(self::CACHE_LIFETIME_7_DAYS);
$this->cache->save($footerCacheItem);
}
$data['nanobars'] = $this->getNanobars($domain, $defaultLocale);
$legalLinks = $this->getLegalLinks($request, $domainId);
$data['privacy_policy_link'] = $legalLinks['privacy_policy'];
$data['cookies_link'] = $legalLinks['cookies'];
if (is_null($request->cookies->get('frb_cookie_consent'))) {
$data['displayCookieConsent'] = true;
} else {
$data['displayCookieConsent'] = false;
// Show cookie for users who declined the modal
if ( $request->cookies->get('frb_cookie_consent') == 'decline' ) {
if ( is_null($request->cookies->get('frb_cookie_consent_2025')) ) {
$data['displayCookieConsent'] = true;
setcookie('frb_cookie_consent_2025', 'ok', time() + ( 60 * 60 * 24 * 30 * 6 ));
}
}
}
if (in_array($domain->getId(), [Domain::DOMAIN_ID_RT_SK, Domain::DOMAIN_ID_RT_HU])) {
$data['displayCookieConsent'] = false;
}
$data['domainId'] = $domain->getId();
$data['loggedInCustomer'] = $this->getLoginHelper($request)->getLoggedInCustomer();
$data['stores'] = $this->storeSwitcher;
if ($data['mode'] == 'standard') {
$data['sidebarMenu'] = $this->getMenu($request, 'mobile');
}
$data['currency'] = $domain->getCurrency();
$data['precision'] = $domain->getPricePrecision();
$data['languages'] = $this->getAvailableLanguagesByDomainId($request, $domain->getId());
return $this->renderView('AtechNetCoreBundle/Common/footer.html.twig', $data);
}
/**
* @param Request $request
* @return string
* @throws \Exception
*/
public function getColumnRight(Request $request)
{
$data = [];
$moduleHelper = $this->getModuleHelper($request);
$route = $this->getRouteName($request);
$data['modules'] = [];
switch ($route) {
case 'blog_main':
case 'blog_show':
case 'blog_show_locale':
// Block Categories
array_push($data['modules'], $moduleHelper->blockBlogCategory());
$blogId = $request->attributes->get('blogId');
// Block Featured
array_push($data['modules'], $moduleHelper->blockBlogFeatured($blogId));
// Block Tag Cloud
array_push($data['modules'], $moduleHelper->blockBlogTagCloud());
break;
case 'blog_main':
case 'blog_show_category':
case 'blog_list_locale':
case 'blog_archive_locale':
case 'blog_main_locale':
case 'blog_show_category_locale':
case 'seo':
// Block Categories
array_push($data['modules'], $moduleHelper->blockBlogCategory());
// Block Tag Cloud
array_push($data['modules'], $moduleHelper->blockBlogTagCloud());
break;
}
return $this->renderView('AtechNetCoreBundle/Common/columnRight.html.twig', $data);
}
/**
* @param Request $request
* @return string
*/
public function getContentTop(Request $request)
{
$data = [];
return $this->renderView('AtechNetCoreBundle/Common/content_top.html.twig', $data);
}
/**
* @param Request $request
* @param null|string $route
* @return string
* @throws \Exception
*/
public function getContentBottom(Request $request, $route = null, $warrantyYear = null)
{
$data = [];
$moduleHelper = $this->getModuleHelper($request);
$route = is_null($route) ? $this->getRouteName($request) : $route;
$data['modules'] = [];
$loggedInCustomer = $this->getLoginHelper($request)->getLoggedInCustomer();
$isPartner = !is_null($loggedInCustomer) && in_array($loggedInCustomer->getDomain()->getId(), MultiStore::getWholesaleDomainIDs());
switch ($route) {
case 'homepage':
case 'product_show':
case 'category_show':
case 'product_search':
case 'customer_login':
case 'customer_registration':
case 'customer_password_reset':
case 'customer_forgot_password':
case 'customer_registration_successful':
case 'customer_login_locale':
case 'customer_registration_locale':
case 'customer_password_reset_locale':
case 'customer_forgot_password_locale':
case 'customer_registration_successful_locale':
// Block Popular Link
array_push($data['modules'], $moduleHelper->blockPopularLink());
break;
case 'customer_claims':
case 'customer_logout':
case 'customer_orders':
case 'customer_account':
case 'customer_address':
case 'customer_claims_new':
case 'customer_newsletter':
case 'customer_address_add':
case 'customer_account_edit':
case 'customer_address_edit':
case 'customer_claims_locale':
case 'customer_logout_locale':
case 'customer_orders_locale':
case 'customer_account_locale':
case 'customer_address_locale':
case 'customer_claims_new_locale':
case 'customer_newsletter_locale':
case 'customer_address_add_locale':
case 'customer_account_edit_locale':
case 'customer_address_edit_locale':
// Block Popular Link
array_push($data['modules'], $moduleHelper->blockPopularLink());
break;
case 'cart_show':
case 'cart_show_locale':
break;
case 'checkout_success':
case 'checkout_success_locale':
break;
case 'contact':
case 'contact_locale':
// Block Popular Link
array_push($data['modules'], $moduleHelper->blockPopularLink());
break;
case 'blog_show':
case 'blog_list':
case 'blog_show_locale':
case 'blog_list_locale':
// Block Popular Link
array_push($data['modules'], $moduleHelper->blockPopularLink());
break;
case 'blog_main':
case 'page_show':
case 'blog_main_locale':
case 'page_show_locale':
if (!$isPartner) {
// Testimonials
array_push($data['modules'], $moduleHelper->blockTestimonial());
}
// Block Popular Link
array_push($data['modules'], $moduleHelper->blockPopularLink());
break;
case 'review_list':
case 'review_list_en':
case 'review_list_sk':
case 'review_list_hu':
case 'review_list_cz':
case 'review_list_locale':
case 'review_list_en_locale':
case 'review_list_sk_locale':
case 'review_list_hu_locale':
case 'review_list_cz_locale':
// Block Popular Link
array_push($data['modules'], $moduleHelper->blockPopularLink());
break;
case 'not_found':
case 'not_found_locale':
// Block Popular Link
array_push($data['modules'], $moduleHelper->blockPopularLink());
break;
}
return $this->renderView('AtechNetCoreBundle/Common/content_bottom.html.twig', $data);
}
/**
* @param Request $request
* @return string
*/
private function getRouteName(Request $request)
{
$route = $request->attributes->get('_route');
$forward = $request->attributes->get('_forward_controller');
if (isset($forward[0], $forward[1])) {
if ($forward[1] == 'listAction' && $forward[0] instanceof \App\AtechNet\CoreBundle\Controller\ProductController) {
$route = 'category_show';
} elseif ($forward[1] == 'showAction' && $forward[0] instanceof \App\AtechNet\CoreBundle\Controller\ProductController) {
$route = 'product_show';
} elseif ($forward[1] == 'showAction' && $forward[0] instanceof \App\AtechNet\CoreBundle\Controller\PageController) {
$route = 'page_show';
} elseif ($forward[1] == 'showBlogAction' && $forward[0] instanceof \App\AtechNet\CoreBundle\Controller\PageController) {
$route = 'blog_show';
} elseif ($forward[1] == 'listBlogAction' && $forward[0] instanceof \App\AtechNet\CoreBundle\Controller\PageController) {
$route = 'blog_list';
} elseif ($forward[1] == 'notFoundAction' && $forward[0] instanceof \App\AtechNet\CoreBundle\Controller\DefaultController) {
$route = 'not_found';
}
}
return $route;
}
/**
* @param Request $request
* @return DatabaseTranslator
* @throws \Exception
*/
public function getDatabaseTranslator(Request $request)
{
return new DatabaseTranslator($this->getEntityManager(), $request->getSession()->get('localeDomainId'));
}
public function getTranslator()
{
return $this->translator;
}
/**
* @param Request $request
* @return ProductHelper
* @throws \Exception
*/
public function getProductHelper(Request $request)
{
return new ProductHelper($this->getEntityManager(), $this->getParameter('cloudflare_image'), $this->getDatabaseTranslator($request), $this->getMultiStoreHelper($request), $this->router, $this->historicalEuroRate);
}
/**
* @param Request $request
* @return MultiStore
*/
public function getMultiStoreHelper(Request $request)
{
return new MultiStore($this->getEntityManager(), $request);
}
/**
* @param Request $request
* @return Module
* @throws \Exception
*/
public function getModuleHelper(Request $request)
{
return new Module($this->getEntityManager(), $request, $this->getProductHelper($request), $this->getParameter('cloudflare_image'), $this->getMultiStoreHelper($request), $this->getDatabaseTranslator($request), $this->url($request), $this->getTranslator(), $this->twig);
}
/**
* @param Request $request
* @return SeoUrlHelper
*/
public function url(Request $request): SeoUrlHelper
{
return new SeoUrlHelper($this->getEntityManager(), $request, $this->getEnvironment());
}
/**
* @param Request $request
* @param string $target
* @return array
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
protected function getMenu(Request $request, string $target = 'desktop'): array
{
// Entity Manager
$entityManager = $this->getEntityManager();
// Multi-Store
$multiStore = $this->getMultiStoreHelper($request);
// SEO URL
$seoUrl = $this->url($request);
// Retail Domain
$domain = $multiStore->getDomain();
$router = $this->router;
// Wholesale Domain
if (in_array($domain->getId(), MultiStore::getWholesaleDomainIDs())) {
$domain = $multiStore->getRetailDomainByWholesaleDomain($domain);
}
// Default Language Id
$defaultLanguageId = $multiStore->getDefaultLanguageId();
// Language Code
$languageCode = $request->getLocale();
// Category Repository
$categoryPageRepository = $entityManager->getRepository(CategoryPage::class);
$categoryPageRepository->setSession($request->getSession());
// Last Changes
$lastChanges = $entityManager->getConnection()->fetchOne('SELECT updated FROM domain_navigation WHERE domain_id = ' . $domain->getId() . ' ORDER BY updated DESC LIMIT 1');
// Cache Key
$cacheKey = 'header.mainMenu.' . $target . '.v24.' . $request->getSession()->get('localeDomainId') . '.' . $languageCode . '.' . strtotime($lastChanges);
// Bazaar
if ( $request->getSession()->get('isBazaarPage') === true ) {
$cacheKey = 'header.mainMenu.' . $target . '.bazaar.v24.' . $request->getSession()->get('localeDomainId') . '.' . $languageCode . '.' . strtotime($lastChanges);
}
// Cache Data
$cacheItem = $this->cache->getItem($cacheKey);
if ($cacheItem->isHit()) {
return $cacheItem->get();
}
// Collection of Routes
$routes = $router->getRouteCollection();
// Menu
$menu = [
'product' => [
'name' => 'Our products',
'href' => false,
'nanobar' => false,
'children' => [],
],
'standard' => [],
'push' => [],
];
// Criteria
$criteria = [
'domain' => $domain,
'parent' => null
];
// Bazaar
if ( $request->getSession()->get('isBazaarPage') === true ) {
$criteria['bazaar'] = true;
}
$domainNavigation = $entityManager->getRepository(DomainNavigation::class)->findBy($criteria, [
'sortIndex' => 'ASC',
]);
/**
* @var DomainNavigation $navigation
*/
foreach ($domainNavigation as $navigationIndex => $navigation) {
// Navigation Type
$navigationType = $navigation->getType();
if ( $navigationType == DomainNavigation::NAVIGATION_TYPE_PRODUCT && $request->getSession()->get('isBazaarPage') === false && $navigation->isBazaar() === true ) {
continue;
}
// Category Page (parent)
$parentCategoryPage = $navigation->getCategoryPage();
// Build Query
$arguments = [];
if (!empty($navigation->getQuery())) {
foreach (explode('&', $navigation->getQuery()) as $argument) {
[$name, $value] = explode('=', $argument);
if (!empty($name) && !empty($value)) {
$arguments[$name] = $value;
}
}
}
// Alternative Navigation
$alternativeNavigation = null;
if ($multiStore->isLanguageSwitched()) {
// Use Alternative Category
if (!is_null($parentCategoryPage)) {
$alternativeParentCategoryPage = $categoryPageRepository->getAlternativeCategoryByLanguage($parentCategoryPage);
if (!is_null($alternativeParentCategoryPage)) {
// Criteria
$_criteria = [
'categoryPage' => $alternativeParentCategoryPage,
'parent' => null
];
// Bazaar
if ( $request->getSession()->get('isBazaarPage') === true ) {
$_criteria['bazaar'] = true;
}
// Alternative Navigations
$alternativeNavigations = $entityManager->getRepository(DomainNavigation::class)->findBy($_criteria);
foreach ($alternativeNavigations as $_alternativeNavigation) {
// Build Alternative Query
$alternativeArguments = [];
if (!empty($_alternativeNavigation->getQuery())) {
foreach (explode('&', $_alternativeNavigation->getQuery()) as $argument) {
[$name, $value] = explode('=', $argument);
if (!empty($name) && !empty($value)) {
$alternativeArguments[$name] = $value;
}
}
}
if (array_diff($arguments, $alternativeArguments) == array_diff($alternativeArguments, $arguments)) {
$alternativeNavigation = $_alternativeNavigation;
continue;
}
}
}
}
// Alternatives to non-identifiable static categories
else {
$alternativeNavigation = $categoryPageRepository->getAlternativeNavigation($navigation);
}
}
// Build Link
if ($parentCategoryPage) {
if ($parentCategoryPage->getType() == CategoryPage::CATEGORY_TYPE_BLOG) {
$link = $seoUrl->link('blog_category', array_merge([
'blog_category_id' => $parentCategoryPage->getId(),
], $arguments));
} else {
$link = $seoUrl->link('category', array_merge([
'path' => $parentCategoryPage->getId(),
'isBazaar' => $parentCategoryPage->isShowOnlyBazaar()
], $arguments));
}
} else {
$context = new RequestContext();
$context->fromRequest($request);
$matcher = new UrlMatcher($routes, $context);
$route = '/' . ltrim($navigation->getRoute(), '/');
$attributes = $matcher->match($route);
if (empty($attributes) || $attributes['_route'] == 'seo') {
// Static Page Seo Url
$staticSeoUrl = $entityManager->getRepository(SeoUrl::class)->findOneBy([
'keyword' => ltrim($navigation->getRoute(), '/'),
'domain' => $domain,
'language' => $defaultLanguageId
]);
if ( empty($staticSeoUrl) ) {
continue;
}
// Explode Url Query
[$type, $static_id] = explode('=', $staticSeoUrl->getQuery());
if ( $type !== 'static_id' ) {
continue;
}
$link = $seoUrl->link('page', array_merge([
$type => $static_id
], $arguments));
} else {
$link = $this->generateUrl($attributes['_route'], $arguments);
}
}
if ( empty($link) ) {
continue;
}
// Product
if ($navigationType == DomainNavigation::NAVIGATION_TYPE_PRODUCT) {
$menu['product']['children'][$navigationIndex] = [
'name' => !is_null($alternativeNavigation) ? $alternativeNavigation->getTitle() : $navigation->getTitle(),
'icon' => $navigation->getSvgIcon(),
'href' => $link,
'children' => false,
];
// Groups
if ($navigation->getChildren()->count() > 0) {
$groups = [];
foreach ($navigation->getChildren() as $groupIndex => $group) {
// Bazaar
if ( $request->getSession()->get('isBazaarPage') === true && !$group->isBazaar() ) {
continue;
}
if (($target == 'desktop' && $group->isDesktop()) || ($target == 'mobile' && $group->isMobile())) {
// Items
if ($group->getChildren()->count() > 0) {
$groups[$groupIndex] = [
'name' => (mb_strpos($group->getTitle(), '#') === false ? $group->getTitle() : ''),
'children' => false,
];
foreach ($group->getChildren() as $itemIndex => $item) {
// Bazaar
if ( $request->getSession()->get('isBazaarPage') === true && !$item->isBazaar() ) {
continue;
}
if (($target == 'desktop' && $item->isDesktop()) || ($target == 'mobile' && $item->isMobile())) {
// Category Page (child)
/** @var CategoryPage $childCategoryPage */
$childCategoryPage = $item->getCategoryPage();
// Skip Blog Category Pages
if ($multiStore->isLanguageSwitched() && !is_null($childCategoryPage) && $childCategoryPage->getType() == CategoryPage::CATEGORY_TYPE_BLOG) {
continue;
}
// Build Query
$arguments = [];
if (!empty($item->getQuery())) {
foreach (explode('&', $item->getQuery()) as $argument) {
if (count(explode('=', $argument)) == 1) {
continue;
}
[$name, $value] = explode('=', $argument);
if (!empty($name) && !empty($value)) {
$arguments[$name] = $value;
}
}
}
// Alternative Child Navigation
$alternativeChildNavigation = null;
// Use Alternative Category by Language
if (!is_null($childCategoryPage) && $multiStore->isLanguageSwitched()) {
$alternativeChildCategoryPage = $categoryPageRepository->getAlternativeCategoryByLanguage($childCategoryPage);
if (is_null($alternativeChildCategoryPage)) {
continue;
}
// Alternative Child Navigations
$alternativeChildNavigations = $entityManager->getRepository(DomainNavigation::class)->findBy([
'categoryPage' => $alternativeChildCategoryPage,
]);
foreach ($alternativeChildNavigations as $_alternativeChildNavigation) {
if (is_null($_alternativeChildNavigation->getParent())) {
continue;
}
if (!is_null($alternativeNavigation) && $_alternativeChildNavigation->getParent()->getParent()->getId() !== $alternativeNavigation->getId()) {
continue;
}
// Build Alternative Query
$alternativeArguments = [];
if (!empty($_alternativeChildNavigation->getQuery())) {
foreach (explode('&', $_alternativeChildNavigation->getQuery()) as $argument) {
try {
[$name, $value] = explode('=', $argument);
} catch (\Exception $exception) {
continue;
}
if (!empty($name) && !empty($value)) {
$alternativeArguments[$name] = $value;
}
}
}
if (array_diff($arguments, $alternativeArguments) == array_diff($alternativeArguments, $arguments)) {
$alternativeChildNavigation = $_alternativeChildNavigation;
continue;
}
}
if (is_null($alternativeChildNavigation)) {
continue;
}
}
// Build Link
if ($childCategoryPage) {
//skip bazaar menu in RT domains
if (
in_array($multiStore->getDomain()->getId(), MultiStore::getRetailDomainIDs())
&& $childCategoryPage->isShowOnlyBazaar()
) {
continue;
}
if ($childCategoryPage->getType() == CategoryPage::CATEGORY_TYPE_BLOG) {
$link = $seoUrl->link('blog_category', array_merge([
'blog_category_id' => $childCategoryPage->getId(),
], $arguments));
} elseif ($childCategoryPage->getParentCategory()) {
$link = $seoUrl->link('category', array_merge([
'path' => $childCategoryPage->getParentCategory()->getId() . '_' . $childCategoryPage->getId(),
'isBazaar' => $childCategoryPage->isShowOnlyBazaar()
], $arguments));
} else {
$link = $seoUrl->link('category', array_merge([
'path' => $childCategoryPage->getId(),
'isBazaar' => $childCategoryPage->isShowOnlyBazaar()
], $arguments));
}
} else {
$context = new RequestContext();
$context->fromRequest($request);
$matcher = new UrlMatcher($routes, $context);
$attributes = $matcher->match($item->getRoute());
if (empty($attributes) || $attributes['_route'] == 'seo') {
continue;
}
$link = $this->generateUrl($attributes['_route'], $arguments);
}
$groups[$groupIndex]['children'][$itemIndex] = [
'title' => !is_null($alternativeChildNavigation) ? $alternativeChildNavigation->getTitle() : $item->getTitle(),
'subTitle' => !is_null($alternativeChildNavigation) ? $alternativeChildNavigation->getSubTitle() : $item->getSubTitle(),
'href' => $link,
'label' => (
!is_null($item->getLabel()) && $item->getLabel() !== DomainNavigation::LABEL_NONE && isset(DomainNavigation::getLabelChoices()[$item->getLabel()])
? mb_strtolower(DomainNavigation::getLabelChoices()[$item->getLabel()]) : false
),
];
}
}
if (!$groups[$groupIndex]['children']) {
unset($groups[$groupIndex]);
}
}
}
}
if (!empty($groups)) {
$menu['product']['children'][$navigationIndex]['children'] = $groups;
}
}
}
// Standard
elseif ($navigationType == DomainNavigation::NAVIGATION_TYPE_STANDARD) {
$menu['standard'][$navigationIndex] = [
'name' => $navigation->getTitle(),
'href' => $link,
'children' => false,
'icon' => $navigation->getSvgIcon(),
];
}
// Pushed to the right
elseif ($navigationType == DomainNavigation::NAVIGATION_TYPE_PUSH) {
$menu['push'][$navigationIndex] = [
'name' => $navigation->getTitle(),
'href' => $link,
'children' => false,
];
}
}
if ($domain->getId() == Domain::DOMAIN_ID_RT_HU){
$menu['standard'][-1] = [
'name' => 'Bestseller',
'href' => 'https://www.furbify.hu/bestseller',
'children' => false,
'icon' => null,
];
} else if ($domain->getId() == Domain::DOMAIN_ID_RT_SK){
$menu['standard'][-1] = [
'name' => 'Bestseller',
'href' => 'https://www.furbify.sk/bestseller',
'children' => false,
'icon' => null,
];
} else if ($domain->getId() == Domain::DOMAIN_ID_RT_CZ){
$menu['standard'][-1] = [
'name' => 'Bestseller',
'href' => 'https://www.furbify.cz/bestseller',
'children' => false,
'icon' => null,
];
} else if ($domain->getId() == Domain::DOMAIN_ID_RT_EU){
$menu['standard'][-1] = [
'name' => 'Sale',
'href' => 'https://www.furbify.eu/sale',
'children' => false,
'icon' => null,
];
}
$currentDate = new \DateTime();
$endDate = new \DateTime('2025-11-30');
$startDate = new \DateTime('2025-11-07');
$blackFridayDateIsActive = $startDate <= $currentDate && $currentDate <= $endDate;
if ($blackFridayDateIsActive) {
$menu['standard'][-1]['name'] = 'BLACK FRIDAY';
$menu['standard'][-1]['href'] = "{$domain->getUrl()}/black-friday";
}
if ( $request->getSession()->get('isBazaarPage') === true ) {
unset($menu['standard'][-1]);
}
ksort($menu['standard']);
$cacheItem->set($menu);
$cacheItem->expiresAfter(self::CACHE_LIFETIME_1_YEAR);
$this->cache->save($cacheItem);
return $menu;
}
/**
* @param Request $request
* @return Login
*/
public function getLoginHelper(Request $request): Login
{
return new Login($this->getEntityManager(), $request, $this->container);
}
/**
* @return array
*/
public function getContactInfos(): array
{
$isYear2025 = date('Y') == '2025';
return [
'mail.webshop.sk.retail' => 'webshop@furbify.sk',
'mail.webshop.hu.retail' => 'webshop@furbify.hu',
'mail.webshop.cz.retail' => 'webshop@furbify.cz',
'mail.webshop.en.retail' => 'webshop@furbify.eu',
'mail.webshop.sk.wholesale' => 'webshop@furbify.sk',
'mail.webshop.hu.wholesale' => 'webshop@furbify.hu',
'mail.webshop.cz.wholesale' => 'webshop@furbify.cz',
'mail.webshop.en.wholesale' => 'zsolt.matusek@furbify.eu',
'mail.warranty.sk.retail' => 'warranty@furbify.sk',
'mail.warranty.hu.retail' => 'warranty@furbify.hu',
'mail.warranty.cz.retail' => 'warranty@furbify.cz',
'mail.warranty.en.retail' => 'warranty@furbify.eu',
'mail.warranty.sk.wholesale' => 'warranty@furbify.sk',
'mail.warranty.hu.wholesale' => 'warranty@furbify.hu',
'mail.warranty.cz.wholesale' => 'warranty@furbify.cz',
'mail.warranty.en.wholesale' => 'warranty@furbify.eu',
'phone.webshop.sk.retail' => '+421 220 512 060',
'phone.webshop.hu.retail' => '+36 17 65 46 57',
'phone.webshop.cz.retail' => '+420 226 400 290',
'phone.webshop.en.retail' => '+421 220 512 060',
'phone.webshop.sk.wholesale' => '+421 220 512 060',
'phone.webshop.hu.wholesale' => '+36 17 65 46 57',
'phone.webshop.cz.wholesale' => '+420 226 400 290',
'phone.webshop.en.wholesale' => '+421 220 512 060',
'phone.warranty.sk.retail' => '+421 220 512 060',
'phone.warranty.hu.retail' => '+36 17 65 46 57',
'phone.warranty.cz.retail' => '+420 226 400 290',
'phone.warranty.en.retail' => '+421 220 512 060',
'phone.warranty.sk.wholesale' => '+421 220 512 060',
'phone.warranty.hu.wholesale' => '+36 17 65 46 57',
'phone.warranty.cz.wholesale' => '+420 226 400 290',
'phone.warranty.en.wholesale' => '+421 220 512 060',
'company.sk.name' => 'furbify s.r.o.',
'company.sk.street' => 'Osada Reviczkého 3869/38',
'company.sk.city' => 'Kolárovo',
'company.sk.zip' => '946 03',
'company.sk.country' => 'Slovenská republika',
'company.sk.id' => '44827385',
'company.sk.vatId' => 'SK2022851589',
'company.sk.bankAccount' => '212959395/0900',
'company.sk.iban' => 'SK45 0900 0000 0002 1295 9395 (Slovenská Sporiteľňa - Erste Group)',
'company.hu.name' => 'furbify s.r.o.',
'company.hu.street' => 'Osada Reviczkého 3869/38',
'company.hu.city' => 'Kolárovo (Gúta)',
'company.hu.zip' => '946 03',
'company.hu.country' => 'Szlovákia',
'company.hu.id' => '44827385',
'company.hu.vatId' => 'SK2022851589',
'company.hu.bankAccount' => '12028209-02010543-00100002',
'company.hu.iban' => 'HU89 1202 8209 0201 0543 0010 0002 (Raiffeisen Bank)',
'company.cz.name' => 'furbify s.r.o.',
'company.cz.street' => 'Osada Reviczkého 3869/38',
'company.cz.city' => 'Kolárovo',
'company.cz.zip' => '946 03',
'company.cz.country' => 'Slovenská republika',
'company.cz.id' => '44827385',
'company.cz.vatId' => 'SK2022851589',
'company.cz.bankAccount' => '4732551359/0800 (Česká spořitelna, a.s.)',
'company.cz.iban' => 'CZ38 0800 0000 0047 3255 1359',
'company.en.name' => 'furbify s.r.o.',
'company.en.street' => 'Osada Reviczkého 3869/38',
'company.en.city' => 'Kolárovo',
'company.en.zip' => '946 03',
'company.en.country' => 'Slovakia',
'company.en.id' => '44827385',
'company.en.vatId' => 'SK2022851589',
'company.en.bankAccount' => '212959395/0900 (SLSP)',
'company.en.iban' => 'SK45 0900 0000 0002 1295 9395',
];
}
/**
* @param Request $request
* @param int $domainId
* @return array
*/
protected function getLegalLinks(Request $request, int $domainId): array
{
$links = [];
$seoUrlHelper = $this->getSeoUrlHelper($request);
switch ($domainId) {
case Domain::DOMAIN_ID_RT_SK:
case Domain::DOMAIN_ID_WS_SK:
$links['terms_conditions'] = $seoUrlHelper->link('page', [
'static_id' => 12,
]);
$links['privacy_policy'] = $seoUrlHelper->link('page', [
'static_id' => 13,
]);
$links['return_policy'] = $seoUrlHelper->link('page', [
'static_id' => 15,
]);
$links['cookies'] = $seoUrlHelper->link('page', [
'static_id' => 37,
]);
break;
case Domain::DOMAIN_ID_RT_HU:
case Domain::DOMAIN_ID_WS_HU:
$links['terms_conditions'] = $seoUrlHelper->link('page', [
'static_id' => 28,
]);
$links['privacy_policy'] = $seoUrlHelper->link('page', [
'static_id' => 29,
]);
$links['return_policy'] = $seoUrlHelper->link('page', [
'static_id' => 31,
]);
$links['cookies'] = $seoUrlHelper->link('page', [
'static_id' => 38,
]);
break;
case Domain::DOMAIN_ID_RT_CZ:
case Domain::DOMAIN_ID_WS_CZ:
$links['terms_conditions'] = $seoUrlHelper->link('page', [
'static_id' => 61,
]);
$links['privacy_policy'] = $seoUrlHelper->link('page', [
'static_id' => 62,
]);
$links['return_policy'] = $seoUrlHelper->link('page', [
'static_id' => 64,
]);
$links['cookies'] = $seoUrlHelper->link('page', [
'static_id' => 68,
]);
break;
case Domain::DOMAIN_ID_RT_EU:
case Domain::DOMAIN_ID_WS_EU:
$links['terms_conditions'] = $seoUrlHelper->link('page', [
'static_id' => 128,
]);
$links['privacy_policy'] = $seoUrlHelper->link('page', [
'static_id' => 123,
]);
$links['return_policy'] = $seoUrlHelper->link('page', [
'static_id' => 127,
]);
$links['cookies'] = $seoUrlHelper->link('page', [
'static_id' => 108,
]);
break;
default:
$links['terms_conditions'] = $seoUrlHelper->link('page', [
'static_id' => 12,
]);
$links['privacy_policy'] = $seoUrlHelper->link('page', [
'static_id' => 13,
]);
$links['return_policy'] = $seoUrlHelper->link('page', [
'static_id' => 15,
]);
$links['cookies'] = $seoUrlHelper->link('page', [
'static_id' => 37,
]);
}
return $links;
}
/**
* @param Request $request
* @return int
*/
protected function getCommissionsCount(Request $request)
{
return $this->getEntityManager()
->createQuery("SELECT COUNT(pc.id) AS commissionCount
FROM AtechNetCoreBundle:ProductCommission pc
WHERE pc.customer = :customer")
->setParameter('customer', $this->getLoginHelper($request)->getLoggedInCustomerId())
->getResult()[0]['commissionCount'];
}
/**
* @return Cetelem
*/
protected function getCetelemHelperSK()
{
return new Cetelem(
$this->getParameter('cetelem_sk_id'),
$this->getEntityManager(),
$this->getTwig(),
__DIR__ . '/../Resources/storage/cetelem',
'cetelem_sk.json'
);
}
/**
* @param Request $request
* @return SeoUrlHelper
*/
protected function getSeoUrlHelper(Request $request): SeoUrlHelper
{
return new SeoUrlHelper($this->getEntityManager(), $request, $this->getEnvironment());
}
/**
* @param Request $request
* @return OrderHelper
* @throws \Exception
*/
protected function getOrderHelper(Request $request): OrderHelper
{
return new OrderHelper(
$request,
$this->getEntityManager(),
$this->getTranslator(),
$this->getDatabaseTranslator($request),
$this->getRouter(),
$this->getMailer(),
$this->getParameter('mailer_reply_to'),
$this->getParameter('cloudflare_image'),
$this->getEnvironment()
);
}
/**
* @param Request $request
* @param int $domainId
* @return array
*/
protected function getAvailableLanguagesByDomainId(Request $request, int $domainId): array
{
// Language Redirect
if ($request->attributes->get('productId')) {
$redirect = [
'productId' => $request->attributes->get('productId'),
];
} elseif ($request->attributes->get('categoryId')) {
$redirect = [
'categoryId' => $request->attributes->get('categoryId'),
];
} elseif ($request->attributes->get('pageId')) {
$redirect = [
'pageId' => $request->attributes->get('pageId'),
];
} elseif ($request->attributes->get('blogId')) {
$redirect = [
'blogId' => $request->attributes->get('blogId'),
];
} elseif ($request->attributes->get('blogCategoryId')) {
$redirect = [
'blogCategoryId' => $request->attributes->get('blogCategoryId'),
];
} elseif ($request->attributes->get('slug')) {
$redirect = [
'slug' => $request->attributes->get('slug'),
];
} elseif ($request->attributes->get('job_id')) {
$redirect = [
'job_id' => $request->attributes->get('job_id'),
];
} else {
$redirect = [
'route' => str_replace('_locale', '', $request->attributes->get('_route')),
];
}
$query = $request->query->all();
$languages = [];
switch ($domainId) {
case Domain::DOMAIN_ID_RT_SK:
case Domain::DOMAIN_ID_WS_SK:
// Default
$parameters = array_merge([
'locale' => 'sk',
], $redirect, $query);
$languages[] = [
'code' => 'sk',
'title' => 'Slovenčina',
'href' => $this->generateUrl('set_locale', $parameters),
];
// Additional - Hungarian
$parameters = array_merge([
'locale' => 'hu',
], $redirect, $query);
$languages[] = [
'code' => 'hu',
'title' => 'Magyar',
'href' => $this->generateUrl('set_locale', $parameters),
];
// Additional - English
$parameters = array_merge([
'locale' => 'en',
], $redirect, $query);
$languages[] = [
'code' => 'en',
'title' => 'English',
'href' => $this->generateUrl('set_locale', $parameters),
];
break;
case Domain::DOMAIN_ID_RT_HU:
case Domain::DOMAIN_ID_WS_HU:
// Default
$parameters = array_merge([
'locale' => 'hu',
], $redirect, $query);
$languages[] = [
'code' => 'hu',
'title' => 'Magyar',
'href' => $this->generateUrl('set_locale', $parameters),
];
// Additional - English
$parameters = array_merge([
'locale' => 'en',
], $redirect, $query);
$languages[] = [
'code' => 'en',
'title' => 'English',
'href' => $this->generateUrl('set_locale', $parameters),
];
break;
case Domain::DOMAIN_ID_RT_CZ:
case Domain::DOMAIN_ID_WS_CZ:
// Default
$parameters = array_merge([
'locale' => 'cz',
], $redirect, $query);
$languages[] = [
'code' => 'cz',
'title' => 'Čeština',
'href' => $this->generateUrl('set_locale', $parameters),
];
// Additional - Slovak
$parameters = array_merge([
'locale' => 'sk',
], $redirect, $query);
$languages[] = [
'code' => 'sk',
'title' => 'Slovenčina',
'href' => $this->generateUrl('set_locale', $parameters),
];
// Additional - English
$parameters = array_merge([
'locale' => 'en',
], $redirect, $query);
$languages[] = [
'code' => 'en',
'title' => 'English',
'href' => $this->generateUrl('set_locale', $parameters),
];
break;
case Domain::DOMAIN_ID_RT_EU:
case Domain::DOMAIN_ID_WS_EU:
// Default
$parameters = array_merge([
'locale' => 'hu',
], $redirect, $query);
$languages[] = [
'code' => 'en',
'title' => 'English',
'href' => $this->generateUrl('set_locale', $parameters),
];
// Additional - Slovak
$parameters = array_merge([
'locale' => 'sk',
], $redirect, $query);
$languages[] = [
'code' => 'sk',
'title' => 'Slovenčina',
'href' => $this->generateUrl('set_locale', $parameters),
];
// Additional - Czech
$parameters = array_merge([
'locale' => 'cz',
], $redirect, $query);
$languages[] = [
'code' => 'cz',
'title' => 'Čeština',
'href' => $this->generateUrl('set_locale', $parameters),
];
// Additional - Hungarian
$parameters = array_merge([
'locale' => 'hu',
], $redirect, $query);
$languages[] = [
'code' => 'hu',
'title' => 'Magyar',
'href' => $this->generateUrl('set_locale', $parameters),
];
break;
}
return $languages;
}
/**
* @param Request $request
* @return array
*/
protected function getBreadCrumbsBase(Request $request): array
{
return [
'text' => $this->getTranslator()->trans('furbify eshop'),
'href' => $this->generateUrl('homepage'),
];
}
protected function getCustomerTypeId(Request $request)
{
return $request->getSession()->get('customerTypeId');
}
protected function getCustomerTypeString(Request $request)
{
return $this->getCustomerTypeId($request) == MultiStore::CUSTOMER_TYPE_WHOLESALE ? 'partner' : 'retail';
}
/**
* @return array
*/
protected function getWhiteListCouponCodes()
{
return ['FURB20191Y', '15FPC19SK', '15FMON19SK', '15FNTB19SK', '15FPC19HU', '15FMON19HU', '15FNTB19HU', 'FBF3YW', 'XCSOKI', 'XMAS', 'extra3'];
}
/**
* @param $cartId
* @return null|object
*/
protected function getCart($cartId)
{
return $this->getEntityManager()->getRepository(Basket::class)->findOneBy([
'id' => $cartId,
'active' => true,
]);
}
/**
* @param $cartId
* @return null|object
*/
protected function getAbandonedCart($cartId)
{
return $this->getEntityManager()->getRepository(Basket::class)->findOneById($cartId);
}
/**
* @return Billingo
*/
protected function getBillingo(): Billingo
{
return new Billingo(
$this->getEntityManager()
);
}
/**
* @param Request $request
* @return GoPayHelper
* @throws \Exception
*/
protected function getGopayHelper(Request $request): GoPayHelper
{
$parameter = $this->getEnvironment() == 'dev' ? 'gopay_sandbox' : 'gopay';
return new GoPayHelper(
$request,
$this->getEntityManager(),
$this->getDatabaseTranslator($request),
$this->getParameter($parameter),
$this->getRouter()
);
}
/**
* @param Request $request
* @return SimplePayHelper
* @throws \Exception
*/
protected function getSimplePayHelper(Request $request): SimplePayHelper
{
return new SimplePayHelper(
$this->getEntityManager(),
$this->getDatabaseTranslator($request),
$this->getRouter(),
$this->getEnvironment(),
$this->getParameter('simplepay'),
);
}
/**
* @param int $domainId
* @param int $limit
* @return array
*/
protected function getHeurekaSiteReviews(int $domainId, int $limit = 0)
{
switch ($domainId) {
case Domain::DOMAIN_ID_RT_SK:
$reviewsUrl = 'https://www.heureka.sk/direct/dotaznik/export-review.php?key=5a2d564d3e7d6b24ff5c14432a3f6750';
break;
case Domain::DOMAIN_ID_RT_CZ:
$reviewsUrl = 'https://www.heureka.cz/direct/dotaznik/export-review.php?key=0c19c896a04dcd0a071fb8ef4a1f3a48';
break;
}
$reviews = [];
$xml = simplexml_load_string(file_get_contents($reviewsUrl));
$reviewsCount = 0;
foreach ($xml->children() as $child) {
$reviewText = $child->summary->__toString();
if ($limit > 0 && $reviewsCount >= $limit) {
continue;
}
if ($reviewText != '') {
$reviews[$reviewsCount]['text'] = preg_replace('/\s+/S', " ", $reviewText);
$reviews[$reviewsCount]['rating'] = round((float)$child->total_rating->__toString());
$reviews[$reviewsCount]['date'] = (new \DateTime())->setTimestamp($child->unix_timestamp->__toString())->format('d.m.Y, H:i');
$reviewsCount++;
}
}
return $reviews;
}
/**
* @param Domain $domain
* @return array
* @throws \Exception
*/
protected function getHiglightedFlashSaleData(Request $request, Domain $domain)
{
$product = false;
$flashSaleProduct = [];
$entityManager = $this->getEntityManager();
$productGroupTitle = 'flashsale';
$productGroupProductData = $this->getProductHelper($request)->getProductGroupProducts($productGroupTitle, $domain);
if (count($productGroupProductData['productGroupProducts']) > 0) {
foreach ($productGroupProductData['productGroupProducts'] as $productGroupProduct) {
if (!$product && ProductHelper::isFlashSaleValidForProduct($productGroupProduct, $domain)) {
$product = $productGroupProduct;
}
}
}
if (!$product) {
$products = $entityManager->createQuery("SELECT p
FROM AtechNetCoreBundle:Product p
LEFT JOIN AtechNetCoreBundle:ProductMeta pm
WITH pm.id = (
SELECT pm2.id
FROM AtechNetCoreBundle:ProductMeta pm2
WHERE pm2.product = p.id AND pm2.domain = " . $domain->getId() . ")
WHERE pm.active = 1 AND p.available > 0 AND pm.orderable = 1 AND pm.listed = 1 AND pm.discounted = 1 AND
((pm.saleStart IS NOT NULL AND pm.saleEnd IS NOT NULL AND pm.saleStart <= :now AND pm.saleEnd >= :now) OR (pm.saleStart IS NOT NULL AND pm.saleEnd IS NULL AND pm.saleStart <= :now) OR (pm.saleStart IS NULL AND pm.saleEnd IS NOT NULL AND pm.saleEnd >= :now))
ORDER BY pm.currentVatPrice ASC")
->setParameter('now', new \DateTime())
->getResult();
if (count($products) > 0) {
foreach ($products as $p) {
if (!$product) {
$product = $p;
} else {
$addedProductType = $product->getType()->getId();
$currentProductType = $p->getType()->getId();
if ($addedProductType != 52 && $currentProductType == 52) {
$product = $p;
} elseif ($addedProductType != 52 && $currentProductType == 60) {
$product = $p;
}
}
}
}
}
if ($product) {
$placeholder = $this->getImage('placeholder.png', '')->resize(Image::PRODUCT_LIST_THUMB_WIDTH, Image::PRODUCT_LIST_THUMB_HEIGHT);
$result = $this->getProductHelper($request)->getStructuredDataForProduct($product, 'list');
$image = $placeholder;
if (is_object($result['images'])) {
$image = $this->getImage($result['images'], 'product/' . $result['code'])->resize(Image::PRODUCT_LIST_THUMB_WIDTH, Image::PRODUCT_LIST_THUMB_HEIGHT);
}
$flashSaleProduct = [
'id' => $result['id'],
'title' => $result['title'],
'vendor' => $result['vendor'],
'labels' => $result['badges'],
'rawPrice' => $result['rawPrice'],
'price' => $result['vatPrice'],
'rawSpecial' => ($result['isDiscounted'] ? $result['rawDiscountPrice'] : false),
'special' => ($result['isDiscounted'] ? $result['discountVatPrice'] : false),
'image' => $image,
'attributes' => $result['attributes'],
'available' => $result['availableQty'],
'href' => $this->url($request)->link('product', [
'product_id' => $result['id'],
'isBazaar' => $result['isBazaar'] ?? 0
]),
'active' => $result['active'],
'timedSalesActive' => $result['timedSalesActive'],
'timedSalesStartDate' => $result['timedSalesStartDate'],
'timedSalesEndDate' => $result['timedSalesEndDate'],
'warrantyYear' => $this->getWarrantyForProductType($domain->getId(), $result['productTypeId'])['year'],
];
}
return $flashSaleProduct;
}
/**
* @return array
*/
public function getGuestAccountIds()
{
return [
MultiStore::GUEST_CUSTOMER_ID_SK,
MultiStore::GUEST_CUSTOMER_ID_HU,
MultiStore::GUEST_CUSTOMER_ID_CZ,
];
}
/**
* @return ActiveCampaignConnect
*/
protected function getActiveCampaignConnect()
{
$accParameters = $this->getParameter('active_campaign');
return new ActiveCampaignConnect(
$this->getEntityManager(),
$accParameters['url'],
$accParameters['api_key']
);
}
/**
* @param string $currency
* @return string
*/
protected function getCurrencyISOForm($currency)
{
switch ($currency) {
case '€':
return 'EUR';
break;
case 'Ft':
case 'FT':
return 'HUF';
break;
case 'Kč':
case 'KČ':
return 'CZK';
break;
}
return '';
}
/**
* @return mixed
*/
protected function getCentralisUser()
{
return $this->getEntityManager()->getRepository(User::class)->findOneById(User::CENTRALIS_USER_ID);
}
/**
* @param Order $order
* @return string
*/
protected function getOrderPrivateKey(Order $order)
{
return md5($order->getCreated()->format('YmDHi'));
}
/**
* @param UploadedFile $file
* @param string $uploadDirectory
* @param array $allowedFileTypes
* @param bool $generateUniqueName
* @return bool|string
*/
protected function uploadFile(UploadedFile $file, $uploadDirectory, $allowedFileTypes = [], $generateUniqueName = true)
{
if (count($allowedFileTypes) > 0 && !in_array($file->getMimeType(), $allowedFileTypes)) {
return false;
}
if ($generateUniqueName) {
$response['filename'] = $this->generateUniqueFileName() . '.' . $file->guessExtension();
} else {
$response['filename'] = $file->getClientOriginalName();
}
$response['originalName'] = $file->getClientOriginalName();
$response['mimeType'] = $file->getMimeType();
$file->move(
'uploads/' . $uploadDirectory,
$response['filename']
);
return $response;
}
/**
* @return string
*/
public function generateUniqueFileName()
{
return md5(uniqid());
}
/**
* @param Customer|null $customer
* @param Request $request
* @return bool
*/
protected function useZeroVat(Customer $customer = null, Request $request)
{
$isCustomerHasVatId = !is_null($customer) && $customer->useZeroVat($customer->getVatId());
$multiStore = $this->getMultiStoreHelper($request);
$domain = $multiStore->getDomain();
$checkoutData = $this->checkoutCustomerIsCompany($request)
&& !in_array($domain->getId(), [
Domain::DOMAIN_ID_RT_SK,
Domain::DOMAIN_ID_WS_SK,
]);
$isDomainRTEU = $domain->getId() == Domain::DOMAIN_ID_RT_EU;
$result = ($isCustomerHasVatId && $checkoutData) || ($isDomainRTEU && $this->checkoutCustomerIsCompany($request));
$request->getSession()->set('useZeroVat', $result);
return $result;
}
/**
* @var Request $request
* @return bool
*/
protected function checkoutCustomerIsCompany(Request $request): bool
{
$sessionCheckout = $request->getSession()->get('checkout');
return is_array($sessionCheckout)
&& array_key_exists('isCompany', $sessionCheckout)
&& $sessionCheckout['isCompany']
&& array_key_exists('billingVatNumber', $sessionCheckout)
&& $sessionCheckout['billingVatNumber'] != null
&& $sessionCheckout['billingVatNumber'] != ''
;
}
/**
* @param $locale
* @return int
*/
protected function getServicesPageLink($locale): int
{
switch ($locale) {
case 'sk':
return 79; // sluzby-furbify
case 'hu':
return 25; // furbify-szolgaltatasok
case 'cz':
return 84; // sluzby-spolecnosti-furbify
case 'en':
return 117; // furbify-services
}
return 0;
}
/**
* @param Domain $domain
* @param string $locale
* @return array
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
protected function getNanobars(Domain $domain, string $locale): array
{
$entityManager = $this->getEntityManager();
$nanobarCacheKey = 'nanobar.v4.' . $domain->getId() . '.' . $locale;
$nanobarCacheItem = $this->cache->getItem($nanobarCacheKey);
if ($nanobarCacheItem->isHit()) {
return $nanobarCacheItem->get();
}
$nanobarResults = $entityManager->getRepository(Nanobar::class)->findBy([
'domain' => $domain->getId(),
'domainNavigation' => null,
'enabled' => 1,
]);
$nanobars = [];
foreach ($nanobarResults as $nanobar) {
if ($nanobar->isActive()) {
$nanobars[] = [
'color' => $nanobar->getColor(),
'message' => $nanobar->getMessage(),
];
}
}
$nanobarCacheItem->set($nanobars);
$nanobarCacheItem->expiresAfter(self::CACHE_LIFETIME_15_MINUTES);
$this->cache->save($nanobarCacheItem);
return $nanobars;
}
/**
* @param string $response
*/
protected function verifyGoogleCaptcha(string $response)
{
$captchaCheckUrl = 'https://www.google.com/recaptcha/api/siteverify';
$siteSecret = env('APP_ENV') == 'dev' ? '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe' : '6LcgtrsUAAAAAJApqqbEgkBpj5M5bK0iGXNd7dO_';
$data = [
'secret' => $siteSecret,
'response' => $response,
];
$ch = curl_init($captchaCheckUrl);
$postString = http_build_query($data, '', '&');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$captchaResponse = json_decode($response, true);
return $captchaResponse['success'];
}
/**
* @param string $textToCheck
* @return string
*/
protected function getTextWithoutEmoji(string $textToCheck): string
{
$regexForEmojiMatch = '([*#0-9](?>\\xEF\\xB8\\x8F)?\\xE2\\x83\\xA3|\\xC2[\\xA9\\xAE]|\\xE2..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?(?>\\xEF\\xB8\\x8F)?|\\xE3(?>\\x80[\\xB0\\xBD]|\\x8A[\\x97\\x99])(?>\\xEF\\xB8\\x8F)?|\\xF0\\x9F(?>[\\x80-\\x86].(?>\\xEF\\xB8\\x8F)?|\\x87.\\xF0\\x9F\\x87.|..(\\xF0\\x9F\\x8F[\\xBB-\\xBF])?|(((?<zwj>\\xE2\\x80\\x8D)\\xE2\\x9D\\xA4\\xEF\\xB8\\x8F\k<zwj>\\xF0\\x9F..(\k<zwj>\\xF0\\x9F\\x91.)?|(\\xE2\\x80\\x8D\\xF0\\x9F\\x91.){2,3}))?))';
$textWithoutEmoji = preg_replace($regexForEmojiMatch, '', $textToCheck);
return trim(preg_replace('/\s+/', ' ', $textWithoutEmoji));
}
/**
* @param int $domainId
* @param string $locale
* @return array
*
* To generate source CSV file see:
* https://docs.google.com/spreadsheets/d/1vMrITAY-4e_dGD9N5DblgjERE4h_G6IGPgdEsHzup_Y/edit?usp=sharing
*/
protected function getPostalCodeAndCityDatabaseByDomain(int $domainId, string $locale): array
{
// Data
$data = [];
// Cache Key
$cacheKey = 'postal-code.city.v1.' . $domainId;
$cacheItem = $this->cache->getItem($cacheKey);
// Postal Code & City Database from Cache
if ($cacheItem->isHit()) {
$data = $cacheItem->get();
} // Build Postal Code & City Database
else {
$databaseFile = dirname(__FILE__, 2) . '/Resources/storage/private/postalCodeCity/postal-codes-' . $locale . '.csv';
if (file_exists($databaseFile)) {
if (($handle = @fopen($databaseFile, 'r')) !== false) {
while (($row = fgetcsv($handle, 255, ',')) !== false) {
// Postal Code
$postalCode = str_replace(' ', '', trim($row[0]));
// City
$city = trim($row[1]);
// Data
$data[] = [
'postalCode' => $postalCode,
'city' => $city,
];
}
fclose($handle);
}
$cacheItem->set($data);
$cacheItem->expiresAfter(self::CACHE_LIFETIME_1_YEAR);
$this->cache->save($cacheItem);
}
}
return $data;
}
/**
* @return SocialShareImageHelper
*/
protected function getSocialShareImageHelper(): SocialShareImageHelper
{
return new SocialShareImageHelper($this->getParameter('cloudflare_image'));
}
/**
* @param object|string $photo
* @param string $directory
* @param bool|null $overwrite
* @return Image
*/
protected function getImage($photo, string $directory = 'product', ?bool $overwrite = null): Image
{
return new Image($this->getParameter('cloudflare_image'), $photo, $directory, $overwrite);
}
/**
* @param int $currentStep
* @return array
*/
protected function checkoutSteps(int $currentStep): array
{
return [
"currentStep" => $currentStep,
"count" => 5,
'withTitle' => true,
'steps' => [
1 => [
'title' => 'Cart',
'link' => $this->generateUrl("cart_show"),
],
2 => [
'title' => 'Customer',
'link' => $this->generateUrl('checkout_customer'),
],
3 => [
'title' => 'Address',
'link' => $this->generateUrl('checkout_customer'),
],
4 => [
'title' => 'Shipping & pay',
'link' => $this->generateUrl('checkout_customer'),
],
5 => [
'title' => 'Review',
'link' => $this->generateUrl('checkout_customer'),
],
],
];
}
/**
* @return SquarePay
*/
protected function getSquarePay(): SquarePay
{
$config = $this->getParameter('square_pay');
return new SquarePay($this->kernel, $config['username'], $config['password']);
}
/**
* @return Packeta
*/
protected function getPacketa(): Packeta
{
$config = $this->getParameter('packeta');
return new Packeta($config['api_key'], $config['api_password'], $this->getEntityManager());
}
/**
* @return array
*/
protected function getCheckoutFooterMenuPagesList(): array
{
return [
Language::LANGUAGE_ID_HU => [
28 => 'ÁSZF',
29 => 'Adatkezelési tájékoztató',
],
Language::LANGUAGE_ID_SK => [
12 => 'Obchodné podmienky',
13 => 'Ochrana osobných údajov',
],
Language::LANGUAGE_ID_CZ => [
61 => 'Obchodní podmínky',
62 => 'Ochrana osobních údajů',
],
Language::LANGUAGE_ID_EN => [
100 => 'Product grades',
128 => 'Terms and conditions',
],
];
}
/**
* @return string
*/
protected function getFromMail()
{
return $this->getKernel()->getEnvironment() == 'prod' ? $this->getParameter('mailer_user') : 'furbifytest@atechnet.sk';
}
/**
* for emails
* @return string
*/
protected function getFromName()
{
return 'furbify webshop';
}
/**
* @return array
*/
protected function getFooterMenuPagesList(): array
{
$translator = $this->getTranslator();
return [
Language::LANGUAGE_ID_HU => [
[
'title' => $translator->trans('Laptops'),
'module' => 'category',
'items' => [
[
'56' => [
'title' => $translator->trans('Refurbished notebook with warranty'),
],
],
[
'583' => [
'title' => $translator->trans('Refurbished Apple notebook'),
],
],
[
'56_57' => [
'title' => $translator->trans('Refurbished Dell notebook'),
],
],
[
'56_58' => [
'title' => $translator->trans('Refurbished HP notebook'),
],
],
[
'56_59' => [
'title' => $translator->trans('Refurbished Lenovo notebook'),
],
],
[
'56_62' => [
'title' => $translator->trans('Refurbished gamer notebook'),
],
],
[
'56_112' => [
'title' => $translator->trans('Refurbished workstation notebook'),
],
],
[
'56' => [
'filter' => '?sort=price&order=asc&limit=24&fa[63]=632',
'title' => $translator->trans('Notebook with full HD display'),
],
],
[
'56_240' => [
'title' => $translator->trans('2in1 notebooks'),
],
],
[
'56_456' => [
'title' => $translator->trans('Notebook bundle'),
],
],
[
'56_249' => [
'title' => $translator->trans('Notebook bazaar'),
],
],
[
'569' => [
'title' => $translator->trans('Colorful laptops'),
],
],
[
'574' => [
'title' => $translator->trans('Windows 11 notebook'),
],
],
],
],
[
'title' => $translator->trans('Computers'),
'module' => 'category',
'items' => [
[
'48' => [
'title' => $translator->trans('Refurbished computer with warranty'),
],
],
[
'48_49' => [
'title' => $translator->trans('Refurbished Dell computer'),
],
],
[
'48_50' => [
'title' => $translator->trans('Refurbished HP computer'),
],
],
[
'48_51' => [
'title' => $translator->trans('Refurbished Lenovo computer'),
],
],
[
'48_85' => [
'title' => $translator->trans('Refurbished All In One computer'),
],
],
[
'48_52' => [
'title' => $translator->trans('Refurbished workstation computer'),
],
],
[
'48_54' => [
'title' => $translator->trans('Computer with monitor'),
],
],
[
'48_178' => [
'title' => $translator->trans('Refurbished mini PC'),
],
],
[
'48_55' => [
'title' => $translator->trans('Gamer PC'),
],
],
[
'48_444' => [
'title' => $translator->trans('Computer bazaar'),
],
],
[
'577' => [
'title' => $translator->trans('Windows 11 PC'),
],
],
],
],
[
'title' => $translator->trans('Monitors'),
'module' => 'category',
'items' => [
[
'78' => [
'title' => $translator->trans('Refurbished monitor'),
],
],
[
'78_80' => [
'title' => $translator->trans('Refurbished Samsung monitor'),
],
],
[
'78_79' => [
'title' => $translator->trans('Refurbished HP monitor'),
],
],
[
'78' => [
'title' => $translator->trans('HDMI monitor'),
'filter' => '?sort=price&order=asc&limit=24&fa[68]=733',
],
],
[
'78' => [
'title' => $translator->trans('IPS monitor'),
'filter' => '?fa[118]=926',
],
],
[
'78' => [
'title' => $translator->trans('Full HD monitor'),
'filter' => '?fa[63]=632',
],
],
[
'78_377' => [
'title' => $translator->trans('Monitor bazaar'),
],
],
[
'78' => [
'title' => $translator->trans('24“ monitor'),
'filter' => '?sort=price&order=asc&limit=24&fa[12]=204',
],
],
[
'78' => [
'title' => $translator->trans('27“ monitor'),
'filter' => '?sort=price&order=asc&limit=24&fa[12]=205',
],
],
[
'78_192' => [
'title' => $translator->trans('Refurbished projector'),
],
],
],
],
[
'title' => $translator->trans('Other products'),
'module' => 'category',
'items' => [
[
'44' => [
'title' => $translator->trans('Notebook parts'),
],
],
[
'44' => [
'title' => $translator->trans('Computer parts'),
],
],
[
'44_66' => [
'title' => $translator->trans('Docking station for notebook'),
],
],
[
'44_45' => [
'title' => $translator->trans('Notebook battery'),
],
],
[
'235' => [
'title' => $translator->trans('Refurbished mobile phones'),
],
],
[
'268' => [
'title' => $translator->trans('Tablet'),
],
],
[
'44_115' => [
'title' => $translator->trans('Printer'),
],
],
[
'115_181' => [
'title' => $translator->trans('Toner'),
],
],
[
'271' => [
'title' => $translator->trans('Smartwatch'),
],
],
],
],
[
'title' => $translator->trans('Useful pages'),
'module' => 'page',
'items' => [
[
172 => [
'title' => $translator->trans('Free Norton subscription'),
],
],
[
'blog_main' => [
'title' => 'Furbify BLOG',
],
],
[
26 => [
'title' => $translator->trans('Frequently asked questions'),
],
],
[
27 => [
'title' => $translator->trans('Quality grading of product'),
],
],
[
'wizard_home' => [
'title' => $translator->trans('wizard_home'),
],
],
[
'review_list_hu' => [
'title' => $translator->trans('Reviews'),
],
],
[
143 => [
'title' => $translator->trans('Laptop repurchase'),
],
],
[
150 => [
'title' => $translator->trans('Furbify installment'),
],
],
[
152 => [
'title' => $translator->trans('PastPay deferred payment'),
],
],
[
164 => [
'title' => $translator->trans('Product renting'),
],
],
],
],
[
'title' => 'Furbify things',
'module' => 'page',
'items' => [
[
21 => [
'title' => $translator->trans('What is a refurbished PC'),
],
],
[
20 => [
'title' => $translator->trans('We are furbify'),
],
],
[
40 => [
'title' => $translator->trans('Price guarantee'),
],
],
[
25 => [
'title' => $translator->trans('Furbify services'),
],
],
[
95 => [
'title' => $translator->trans('We are Green'),
],
],
[
'product_zsakbamacska_hu' => [
'title' => $translator->trans('Furbify lucky bag'),
],
],
[
140 => [
'title' => $translator->trans('Furbify media'),
],
],
/*[
42 => [
'title' => $translator->trans('Newsletter'),
],
],*/
[
'jobs_hu' => [
'title' => $translator->trans('Job offers'),
],
],
],
],
[
'title' => $translator->trans('Terms and conditions'),
'module' => 'page',
'items' => [
[
'28' => [
'title' => $translator->trans('General terms and conditions'),
],
],
[
'29' => [
'title' => $translator->trans('Privacy policy'),
],
],
[
'202' => [
'title' => $translator->trans('Shipping, Returns & Claims'),
],
],
[
'30' => [
'title' => $translator->trans('Shipping'),
],
],
[
'34' => [
'title' => $translator->trans('Company details'),
],
],
[
'warranty_chech_page_hu' => [
'title' => $translator->trans('Warranty check'),
],
],
],
],
],
Language::LANGUAGE_ID_SK => [
[
'title' => $translator->trans('Laptops'),
'module' => 'category',
'items' => [
[
'5' => [
'title' => $translator->trans('Refurbished notebook with warranty'),
],
],
[
'584' => [
'title' => $translator->trans('Refurbished Apple notebook'),
],
],
[
'5_18' => [
'title' => $translator->trans('Refurbished Dell notebook'),
],
],
[
'5_19' => [
'title' => $translator->trans('Refurbished HP notebook'),
],
],
[
'5_20' => [
'title' => $translator->trans('Refurbished Lenovo notebook'),
],
],
[
'5_24' => [
'title' => $translator->trans('Refurbished gamer notebook'),
],
],
[
'5_113' => [
'title' => $translator->trans('Refurbished workstation notebook'),
],
],
[
'5' => [
'filter' => '?sort=price&order=asc&limit=24&fa[63]=632',
'title' => $translator->trans('Notebook with full HD display'),
],
],
[
'5_241' => [
'title' => $translator->trans('2in1 notebooks'),
],
],
[
'5_455' => [
'title' => $translator->trans('Notebook bundle'),
],
],
[
'250' => [
'title' => $translator->trans('Notebook bazaar'),
],
],
[
'570' => [
'title' => $translator->trans('Colorful laptops'),
],
],
[
'573' => [
'title' => $translator->trans('Windows 11 notebook'),
],
],
],
],
[
'title' => $translator->trans('Computers'),
'module' => 'category',
'items' => [
[
'4' => [
'title' => $translator->trans('Refurbished computer with warranty'),
],
],
[
'4_11' => [
'title' => $translator->trans('Refurbished Dell computer'),
],
],
[
'4_12' => [
'title' => $translator->trans('Refurbished HP computer'),
],
],
[
'4_13' => [
'title' => $translator->trans('Refurbished Lenovo computer'),
],
],
[
'4_84' => [
'title' => $translator->trans('Refurbished All In One computer'),
],
],
[
'4_14' => [
'title' => $translator->trans('Refurbished workstation computer'),
],
],
[
'4_16' => [
'title' => $translator->trans('Computer with monitor'),
],
],
[
'4_177' => [
'title' => $translator->trans('Refurbished mini PC'),
],
],
[
'4_17' => [
'title' => $translator->trans('Gamer PCs'),
],
],
[
'4_443' => [
'title' => $translator->trans('Computer bazaar'),
],
],
[
'578' => [
'title' => $translator->trans('Windows 11 PC'),
],
],
],
],
[
'title' => $translator->trans('Monitors'),
'module' => 'category',
'items' => [
[
'6' => [
'title' => $translator->trans('Refurbished monitor'),
],
],
[
'6_39' => [
'title' => $translator->trans('Refurbished Samsung monitor'),
],
],
[
'6_38' => [
'title' => $translator->trans('Refurbished HP monitor'),
],
],
[
'6' => [
'title' => $translator->trans('HDMI monitor'),
'filter' => '?sort=price&order=asc&limit=24&fa[68]=733',
],
],
[
'6' => [
'title' => $translator->trans('IPS monitor'),
'filter' => '?fa[118]=926',
],
],
[
'6' => [
'title' => $translator->trans('Full HD monitor'),
'filter' => '?fa[63]=632',
],
],
[
'6_378' => [
'title' => $translator->trans('Monitor bazaar'),
],
],
[
'6' => [
'title' => $translator->trans('24“ monitor'),
'filter' => '?sort=price&order=asc&limit=24&fa[12]=204',
],
],
[
'6' => [
'title' => $translator->trans('27“ monitor'),
'filter' => '?sort=price&order=asc&limit=24&fa[12]=205',
],
],
[
'6_191' => [
'title' => $translator->trans('Refurbished projector'),
],
],
],
],
[
'title' => $translator->trans('Other products'),
'module' => 'category',
'items' => [
[
'447' => [
'title' => $translator->trans('Notebook parts'),
],
],
[
'447' => [
'title' => $translator->trans('Computer parts'),
],
],
[
'447_9' => [
'title' => $translator->trans('Docking station for notebook'),
],
],
[
'447_234' => [
'title' => $translator->trans('Notebook battery'),
],
],
[
'236' => [
'title' => $translator->trans('Refurbished mobile phones'),
],
],
[
'269' => [
'title' => $translator->trans('Tablets'),
],
],
[
'114' => [
'title' => $translator->trans('Printers'),
],
],
[
'114_180' => [
'title' => $translator->trans('Toners'),
],
],
[
'272' => [
'title' => $translator->trans('Smart watch'),
],
],
],
],
[
'title' => $translator->trans('Useful pages'),
'module' => 'page',
'items' => [
[
173 => [
'title' => $translator->trans('Free Norton subscription'),
],
],
[
'blog_main' => [
'title' => $translator->trans('Furbify BLOG'),
],
],
[
10 => [
'title' => $translator->trans('Frequently asked questions'),
],
],
[
11 => [
'title' => $translator->trans('Quality grading of product'),
],
],
[
'wizard_home' => [
'title' => $translator->trans('wizard_home'),
],
],
[
'review_list_sk' => [
'title' => $translator->trans('review_list'),
],
],
[
144 => [
'title' => $translator->trans('Laptop repurchase'),
],
],
[
153 => [
'title' => $translator->trans('PastPay deferred payment'),
],
],
[
157 => [
'title' => $translator->trans('Payment in installments'),
],
],
[
165 => [
'title' => $translator->trans('Product renting'),
],
],
],
],
[
'title' => 'Furbify things',
'module' => 'page',
'items' => [
[
4 => [
'title' => $translator->trans('What is a refurbished PC'),
],
],
[
50 => [
'title' => $translator->trans('We are furbify'),
],
],
[
41 => [
'title' => $translator->trans('Price guarantee'),
],
],
[
79 => [
'title' => $translator->trans('Furbify services'),
],
],
[
49 => [
'title' => $translator->trans('Furbify PC shop'),
],
],
/*[
43 => [
'title' => $translator->trans('Newsletter'),
],
],*/
[
'jobs_sk' => [
'title' => $translator->trans('Job offers'),
],
],
],
],
[
'title' => $translator->trans('Terms and conditions'),
'module' => 'page',
'items' => [
[
12 => [
'title' => $translator->trans('General terms and conditions'),
],
],
[
13 => [
'title' => $translator->trans('Privacy policy'),
],
],
[
203 => [
'title' => $translator->trans('Shipping, Returns & Claims'),
],
],
[
14 => [
'title' => $translator->trans('Shipping'),
],
],
[
18 => [
'title' => $translator->trans('Company details'),
],
],
[
'warranty_chech_page_sk' => [
'title' => $translator->trans('Warranty check'),
],
],
],
],
],
Language::LANGUAGE_ID_CZ => [
[
'title' => $translator->trans('Laptops'),
'module' => 'category',
'items' => [
[
'130' => [
'title' => $translator->trans('Refurbished notebook with warranty'),
],
],
[
'585' => [
'title' => $translator->trans('Refurbished Apple notebook'),
],
],
[
'131' => [
'title' => $translator->trans('Refurbished Dell notebook'),
],
],
[
'130_132' => [
'title' => $translator->trans('Refurbished HP notebook'),
],
],
[
'130_133' => [
'title' => $translator->trans('Refurbished Lenovo notebook'),
],
],
[
'130_175' => [
'title' => $translator->trans('Refurbished workstation notebook'),
],
],
[
'130' => [
'filter' => '?sort=price&order=asc&limit=24&fa[63]=632',
'title' => $translator->trans('Notebook with full HD display'),
],
],
[
'130_242' => [
'title' => $translator->trans('2in1 notebooks'),
],
],
[
'130_457' => [
'title' => $translator->trans('Notebook bundle'),
],
],
[
'130_251' => [
'title' => $translator->trans('Notebook bazaar'),
],
],
[
'571' => [
'title' => $translator->trans('Colorful laptops'),
],
],
[
'575' => [
'title' => $translator->trans('Windows 11 notebook'),
],
],
],
],
[
'title' => $translator->trans('Computers'),
'module' => 'category',
'items' => [
[
'122' => [
'title' => $translator->trans('Refurbished computer with warranty'),
],
],
[
'122_155' => [
'title' => $translator->trans('Refurbished All In One computer'),
],
],
[
'122_126' => [
'title' => $translator->trans('Refurbished workstation computer'),
],
],
[
'122_128' => [
'title' => $translator->trans('Computer with monitor'),
],
],
[
'122_179' => [
'title' => $translator->trans('Refurbished mini PC'),
],
],
[
'122_129' => [
'title' => $translator->trans('Gamer PCs'),
],
],
[
'122_445' => [
'title' => $translator->trans('Computer bazaar'),
],
],
[
'579' => [
'title' => $translator->trans('Windows 11 PC'),
],
],
],
],
[
'title' => $translator->trans('Monitors'),
'module' => 'category',
'items' => [
[
'149' => [
'title' => $translator->trans('Refurbished monitor'),
],
],
[
'149_151' => [
'title' => $translator->trans('Refurbished Samsung monitor'),
],
],
[
'149_150' => [
'title' => $translator->trans('Refurbished HP monitor'),
],
],
[
'149' => [
'title' => $translator->trans('HDMI monitor'),
'filter' => '?sort=price&order=asc&limit=24&fa[68]=733',
],
],
[
'149' => [
'title' => $translator->trans('IPS monitor'),
'filter' => '?fa[118]=926',
],
],
[
'149' => [
'title' => $translator->trans('Full HD monitor'),
'filter' => '?fa[63]=632',
],
],
[
'149_379' => [
'title' => $translator->trans('Monitor bazaar'),
],
],
[
'149' => [
'title' => $translator->trans('24“ monitor'),
'filter' => '?sort=price&order=asc&limit=24&fa[12]=204',
],
],
[
'149' => [
'title' => $translator->trans('27“ monitor'),
'filter' => '?sort=price&order=asc&limit=24&fa[12]=205',
],
],
[
'149_193' => [
'title' => $translator->trans('Refurbished projector'),
],
],
],
],
[
'title' => $translator->trans('Other products'),
'module' => 'category',
'items' => [
[
'446' => [
'title' => $translator->trans('Notebook parts'),
],
],
[
'446' => [
'title' => $translator->trans('Computer parts'),
],
],
[
'446_120' => [
'title' => $translator->trans('Docking station for notebook'),
],
],
[
'446_119' => [
'title' => $translator->trans('Notebook battery'),
],
],
[
'239' => [
'title' => $translator->trans('Refurbished mobile phones'),
],
],
[
'270' => [
'title' => $translator->trans('Tablets'),
],
],
[
'176' => [
'title' => $translator->trans('Printers'),
],
],
[
'176_182' => [
'title' => $translator->trans('Toners'),
],
],
[
'364' => [
'title' => $translator->trans('Smart watch'),
],
],
],
],
[
'title' => $translator->trans('Useful pages'),
'module' => 'page',
'items' => [
[
'blog_main' => [
'title' => $translator->trans('Furbify BLOG'),
],
],
[
59 => [
'title' => $translator->trans('Frequently asked questions'),
],
],
[
60 => [
'title' => $translator->trans('Quality grading of product'),
],
],
[
'wizard_home' => [
'title' => $translator->trans('wizard_home'),
],
],
[
'review_list_cz' => [
'title' => $translator->trans('review_list'),
],
],
[
145 => [
'title' => $translator->trans('Laptop repurchase'),
],
],
[
169 => [
'title' => $translator->trans('Payment in installments'),
],
],
[
155 => [
'title' => $translator->trans('PastPay deferred payment'),
],
],
],
],
[
'title' => 'Furbify things',
'module' => 'page',
'items' => [
[
54 => [
'title' => $translator->trans('What is a refurbished PC'),
],
],
[
74 => [
'title' => $translator->trans('We are furbify'),
],
],
[
69 => [
'title' => $translator->trans('Price guarantee'),
],
],
[
84 => [
'title' => $translator->trans('Furbify services'),
],
],
/*[
70 => [
'title' => $translator->trans('Newsletter'),
],
],*/
[
'jobs_cz' => [
'title' => $translator->trans('Job offers'),
],
],
],
],
[
'title' => $translator->trans('Terms and conditions'),
'module' => 'page',
'items' => [
[
61 => [
'title' => $translator->trans('General terms and conditions'),
],
],
[
62 => [
'title' => $translator->trans('Privacy policy'),
],
],
[
204 => [
'title' => $translator->trans('Shipping, Returns & Claims'),
],
],
[
63 => [
'title' => $translator->trans('Shipping'),
],
],
[
77 => [
'title' => $translator->trans('Company details'),
],
],
[
'warranty_chech_page_cz' => [
'title' => $translator->trans('Warranty check'),
],
],
],
],
],
Language::LANGUAGE_ID_EN => [
[
'title' => $translator->trans('Laptops'),
'module' => 'category',
'items' => [
[
'285' => [
'title' => $translator->trans('Refurbished laptops'),
],
],
[
'291' => [
'title' => $translator->trans('Gaming laptop'),
],
],
[
'346' => [
'title' => $translator->trans('Mobile workstation'),
],
],
[
'352' => [
'title' => $translator->trans('2 in 1 laptop'),
],
],
[
'353' => [
'title' => $translator->trans('Chromebook'),
],
],
[
'593' => [
'title' => $translator->trans('Bazaar'),
],
],
[
'285' => [
'filter' => '?sort=price&order=asc&limit=24&fd=1',
'title' => $translator->trans('Laptop sale'),
],
],
],
],
[
'title' => $translator->trans('PC'),
'module' => 'category',
'items' => [
[
'277' => [
'title' => $translator->trans('Refurbished computers'),
],
],
[
'277_310' => [
'title' => $translator->trans('All in one PC'),
],
],
[
'277_284' => [
'title' => $translator->trans('Gamer PC'),
],
],
[
'277_323' => [
'title' => $translator->trans('Mini PC'),
],
],
[
'277_283' => [
'title' => $translator->trans('PC set'),
],
],
[
'277_281' => [
'title' => $translator->trans('Workstation PC'),
],
],
[
'277_594' => [
'title' => $translator->trans('Bazaar'),
],
],
[
'277' => [
'filter' => '?sort=price&order=asc&limit=24&fd=1',
'title' => $translator->trans('PC sale'),
],
],
],
],
[
'title' => $translator->trans('Monitor'),
'module' => 'category',
'items' => [
[
'304' => [
'title' => $translator->trans('Refurbished monitors'),
],
],
[
'348' => [
'title' => $translator->trans('Projectors'),
],
],
[
'317' => [
'title' => $translator->trans('Interactive boards'),
],
],
[
'595' => [
'title' => $translator->trans('Bazaar'),
],
],
[
'304' => [
'filter' => '?sort=price&order=asc&limit=24&fd=1',
'title' => $translator->trans('Monitor sale'),
],
],
],
],
[
'title' => $translator->trans('Other products'),
'module' => 'category',
'items' => [
[
'350' => [
'title' => $translator->trans('Refurbished smartphone'),
],
],
[
'360' => [
'title' => $translator->trans('Refurbished tablet'),
],
],
[
'273_275' => [
'title' => $translator->trans('Docking station'),
],
],
[
'458' => [
'title' => $translator->trans('Components and spare parts'),
],
],
[
'273' => [
'title' => $translator->trans('Accessories'),
],
],
],
],
[
'title' => $translator->trans('About'),
'module' => 'page',
'items' => [
[
'96' => [
'title' => $translator->trans('What are refurbished devices?'),
],
],
[
'114' => [
'title' => $translator->trans('About Us'),
],
],
// ['000' => ['title' => $translator->trans('Why Choose Refurbished?')]],
[
'156' => [
'title' => $translator->trans('Sustainability'),
],
],
[
'99' => [
'title' => $translator->trans('FAQ'),
],
],
[
'100' => [
'title' => $translator->trans('Product grades'),
],
],
[
'wizard_home' => [
'title' => $translator->trans('wizard_home'),
],
],
],
],
[
'title' => $translator->trans('Legal'),
'module' => 'page',
'items' => [
[
'106' => [
'title' => $translator->trans('Company Information'),
],
],
[
'123' => [
'title' => $translator->trans('Privacy policy'),
],
],
[
'102' => [
'title' => $translator->trans('General Terms & Conditions'),
],
],
[
'154' => [
'title' => $translator->trans('Shipping, Returns & Claims'),
],
],
[
'108' => [
'title' => $translator->trans('Cookie Policy'),
],
],
[
'170' => [
'title' => $translator->trans('Payment in installments'),
],
],
],
],
[
'title' => $translator->trans('User'),
'module' => 'page',
'items' => [
[
'customer_registration' => [
'title' => $translator->trans('Registration'),
],
],
[
'customer_login' => [
'title' => $translator->trans('Login'),
],
],
[
'partner_login' => [
'title' => $translator->trans('Wholesale'),
],
],
[
'warranty_chech_page_en' => [
'title' => $translator->trans('Warranty check'),
],
],
],
],
],
];
}
/**
* @return Environment
*/
protected function getTwig(): Environment
{
return $this->twig;
}
/**
* @return KernelInterface
*/
protected function getKernel(): KernelInterface
{
return $this->kernel;
}
/**
* @return string
*/
protected function getEnvironment(): string
{
return $this->getKernel()->getEnvironment();
}
/**
* @return MailerInterface
*/
protected function getMailer(): MailerInterface
{
return $this->mailer;
}
/**
* @return UrlGeneratorInterface
*/
protected function getRouter(): UrlGeneratorInterface
{
return $this->router;
}
/**
* Generates a URL from the given parameters.
* Overwrite the original function because of locale settings
*
* @param string $route
* @param array $parameters
* @param int $referenceType
* @return string
*/
protected function generateUrl(string $route, array $parameters = [], int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): string
{
// Determine locale if the _locale parameter is missing
if (!isset($parameters['_locale'])) {
$parameters['_locale'] = $this->getRoutePrefix() ;
}
// Add local flag if locale is set
if ($parameters['_locale'] !== '') {
try {
// Return route with locale flag if it is exists
return $this->router->generate($route . '_locale', $parameters, $referenceType);
} catch (RouteNotFoundException $e) {
// Catch error if route with locale flag is not exists and do nothing
}
// Remove _locale parameter
unset($parameters['_locale']);
}
// Return route with default locale
return $this->router->generate($route, $parameters, $referenceType);
}
/**
* Determine and return prefix for route based on locale settings
* @return string
*/
public function getRoutePrefix(): string
{
if (!is_null($this->requestStack->getCurrentRequest())) {
return SeoUrlHelper::getRoutePrefix($this->requestStack->getCurrentRequest());
}
return '';
}
/*
* @return Instacash
*/
protected function getInstacash(string $languageCode): Instacash
{
$config = $this->getParameter('instacash')[$languageCode];
return new Instacash($config['api_key'], $config['financier'], $this->getEntityManager(), $this->kernel->getEnvironment(), $this->cache, $languageCode);
}
/**
* @param string $languageCode
*
* @return Milpay
*/
protected function getMilpay(string $languageCode): Milpay
{
$env = $this->getEnvironment();
$config = $this->getParameter('milpay')[$languageCode][$env];
return new Milpay($config['api_key'], $config['offerId'], $this->getEntityManager(), $env, $this->cache, $languageCode);
}
/**
* @param int $domainId
* @return PastPay
*/
protected function getPastPay(int $domainId): PastPay
{
$env = $this->kernel->getEnvironment();
$config = $env == 'prod' ? $this->getParameter("past_pay") : $this->getParameter("past_pay_demo");
return new PastPay($config["api_key_sk"], $this->getEntityManager(), $env);
}
/**
* @param int $domainId
* @param Request $request
* @param string|null $shippingCountry
* @param array $coupon
*
* @return Klarna|null
* @throws \Doctrine\ORM\Exception\NotSupported
* @throws \Random\RandomException
*/
protected function getKlarna(int $domainId, Request $request, string $shippingCountry = null, array $coupon = []): ?Klarna
{
$env = $this->kernel->getEnvironment();
$klarnaServices = [
Domain::DOMAIN_ID_RT_SK => 'klarna_sk',
Domain::DOMAIN_ID_RT_HU => 'klarna_hu',
Domain::DOMAIN_ID_RT_CZ => 'klarna_cz',
Domain::DOMAIN_ID_RT_EU => 'klarna_eu',
];
if (!isset($klarnaServices[$domainId])) {
return null;
}
$config = $env == 'prod'
? $this->getParameter($klarnaServices[$domainId])
: $this->getParameter("klarna_test");
$country = [];
switch ($domainId) {
case Domain::DOMAIN_ID_RT_SK:
$country['purchase_country'] = 'SK';
$country['purchase_currency'] = 'EUR';
$country['locale'] = 'sk-SK';
$country['domain'] = $env == 'prod' ? 'furbify.sk' : 'furbify.dev.sk';
break;
case Domain::DOMAIN_ID_RT_HU:
$country['purchase_country'] = 'HU';
$country['purchase_currency'] = 'HUF';
$country['locale'] = 'hu-HU';
$country['domain'] = $env == 'prod' ? 'furbify.hu' : 'furbify.dev.hu';
break;
case Domain::DOMAIN_ID_RT_CZ:
$country['purchase_country'] = 'CZ';
$country['purchase_currency'] = 'CZK';
$country['locale'] = 'cs-CZ';
$country['domain'] = $env == 'prod' ? 'furbify.cz' : 'furbify.dev.cz';
break;
case Domain::DOMAIN_ID_RT_EU:
$country['locale'] = 'en-' . $shippingCountry;
$country['purchase_country'] = $shippingCountry;
$country['domain'] = $env == 'prod' ? 'furbify.eu' : 'furbify.dev.eu';
$country['purchase_currency'] = 'EUR';
break;
}
$domain = $this->getEntityManager()->getRepository(Domain::class)->find($domainId);
$country['vat'] = $domain->getVat();
$translator = $this->getDatabaseTranslator($request);
return new Klarna($this->getEntityManager(), $env, $country, $config['username'], $config['password'], $coupon, $domain, $translator);
}
/**
* DigitalOcean Space Connection
*
* @return DigitalOceanSpaces
*/
public function getDigitalOceanSpace(): DigitalOceanSpaces
{
$config = $this->getParameter('digital_ocean_space');
return ( new DigitalOceanSpaces($config['access_key'], $config['secret_key']) );
}
protected function getPaypal()
{
$env = $this->kernel->getEnvironment();
$credentials = $env == 'prod'
? $this->getParameter('paypal')['live']
: $this->getParameter('paypal')['sandbox'];
return new Paypal($env, $credentials);
}
protected function getKlaviyoConnect(Request $request): KlaviyoConnect
{
$env = $this->kernel->getEnvironment();
$config = $this->getParameter('klaviyo')[$env];
return new KlaviyoConnect($config, $this->getEntityManager(), $env, $this->getRouter(), $this->getDatabaseTranslator($request)) ;
}
}