26 Commits

Author SHA1 Message Date
0da1aa4ff6 Country stats and searching by exact model name.
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-24 08:44:23 +01:00
59f10e620f Add country name when filtering by country name
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-23 08:37:12 +01:00
9f322d874e Add link to now lowest badge
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-23 08:29:46 +01:00
10cd2c59a3 Add countries selector
All checks were successful
/ deploy-job (push) Successful in 1s
2026-02-22 09:37:19 +01:00
810643c18a Start working on filtering by country
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-21 08:40:07 +01:00
ad0ef20fc2 Country badge.
All checks were successful
/ deploy-job (push) Successful in 1s
2026-02-19 09:33:56 +01:00
e68389bccc Add locale badges to promos 2026-02-19 09:33:56 +01:00
e1dbdc539b Badges as links 2026-02-19 09:33:56 +01:00
f0f26ad64d Badges as links 2026-02-19 09:33:56 +01:00
c6c11d5f7f Merge pull request 'Add the rest of available countries.' (#48) from feature/new-countries into master
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-17 09:34:55 +01:00
7373657d78 Merge branch 'refs/heads/master' into feature/new-countries
All checks were successful
/ deploy-job (push) Successful in 0s
# Conflicts:
#	src/Command/Migrate.php
#	templates/product.html.twig
#	templates/productList.html.twig
2026-02-17 09:32:38 +01:00
3431c0c131 Add update script.
All checks were successful
/ deploy-job (push) Successful in 1s
2026-02-09 21:29:52 +01:00
a2109a601b Add update script.
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-09 21:27:33 +01:00
fc63580305 Add update script.
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-09 21:26:55 +01:00
695da689ac Add update script. 2026-02-09 21:26:40 +01:00
69dd3ce823 Add update script.
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-09 15:05:08 +01:00
88daeef9ec Add update script.
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-09 15:04:09 +01:00
b553c15578 Add update script.
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-09 15:01:47 +01:00
7bb3320e51 First test of gitea actions
All checks were successful
/ deploy-job (push) Successful in 1s
2026-02-09 13:44:14 +01:00
befcef9e8d First test of gitea actions
All checks were successful
/ deploy-job (push) Successful in 0s
2026-02-08 12:58:36 +01:00
cba20f6a61 First test of gitea actions
Some checks failed
/ deploy-job (push) Failing after 0s
2026-02-08 12:56:11 +01:00
074de13175 Fix product chart values for stock and price. 2026-02-08 12:30:27 +01:00
7e2658b174 Upgrade symfony from 7 to 8. Remove cache since it is now faster to open website. 2026-02-07 09:28:38 +01:00
1303b4ad8a Add country option to scrape command. 2026-02-06 08:34:31 +01:00
3bbf82f897 Start working on handling multiple countries at once 2026-01-19 08:40:01 +01:00
a388b53cff Add the rest of available countries. 2026-01-19 08:33:19 +01:00
23 changed files with 529 additions and 498 deletions

View File

@@ -0,0 +1,15 @@
on:
push:
workflow_dispatch:
jobs:
deploy-job:
runs-on: server
steps:
- name: initial test
run: echo "test"
- name: get page
run: curl http://192.168.0.129:9001/update
- run: pwd
- run: cd ../ && pwd
- run: pwd
- run: cd /var/www/html/ryobi-crawler && bin/update

View File

@@ -1,2 +1,4 @@
#!/usr/bin/env bash
bin/cli rm -rf var/cache
echo "Cleaning cache"
bin/cli rm -rf var/cache
echo "cache cleaned2"

View File

@@ -1,18 +1,18 @@
{
"require": {
"guzzlehttp/guzzle": "^7.0",
"guzzlehttp/guzzle": "^7",
"illuminate/database": "11.26.0.0",
"ext-json": "*",
"symfony/console": "^7.0",
"symfony/routing": "^7.1",
"symfony/console": "^8.0",
"symfony/routing": "^8.0",
"laravel/serializable-closure": "^1.3",
"symfony/http-kernel": "^7.1",
"symfony/framework-bundle": "^7.1",
"symfony/twig-bundle": "^7.1",
"symfony/dotenv": "^7.1",
"symfony/http-kernel": "^8.0",
"symfony/framework-bundle": "^8.0",
"symfony/twig-bundle": "^8.0",
"symfony/dotenv": "^8.0",
"twig/intl-extra": "^3.13",
"twig/extra-bundle": "^3.13",
"symfony/cache": "^7.2",
"symfony/cache": "^8.0",
"twig/cache-extra": "^3.21"
},
"autoload": {
@@ -21,6 +21,7 @@
}
},
"require-dev": {
"symfony/var-dumper": "^7.1"
}
"symfony/var-dumper": "^8.0"
},
"minimum-stability": "stable"
}

623
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,84 +0,0 @@
<?php
declare(strict_types=1);
namespace Krzysiej\RyobiCrawler\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\HttpFoundation\Request;
use Illuminate\Database\Capsule\Manager as Capsule;
use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Twig\Environment;
#[AsCommand(name: 'app:cache:warm-twig', description: 'Warmup twig cache')]
class CacheWarmCommand extends Command
{
public function __construct(
private Environment $twig,
private RequestStack $requestStack,
private FilesystemAdapter $cache,
) {
parent::__construct();
}
public function execute(InputInterface $input, OutputInterface $output): int
{
$this->cache->clear();
$capsule = new Capsule;
$capsule->addConnection([
'driver' => 'sqlite',
'database' => __DIR__ . '/../../database.sqlite',
]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
$progress = new ProgressBar($output);
$progress->start();
$products = Product::with([
'price' => fn($query) => $query->orderByDesc('created_at'),
'stock' => fn($query) => $query->orderByDesc('created_at'),
])->get();
$progress->setMaxSteps(count($products));
$request = Request::create('/cache-warm');
$this->requestStack->push($request);
foreach ($products as $product) {
$priceList = $product->price()->pluck('price');
$stockList = $product->stock()->pluck('stock');
$priceDates = $product->price()->pluck('created_at')->map(fn($date) => $date->format('Y-m-d'))->toArray();
$stockDates = $product->stock()->pluck('created_at')->map(fn($date) => $date->format('Y-m-d'))->toArray();
$this->twig->render('product.html.twig', [
'product' => $product,
'price_list' => $this->prepareChartData($priceDates, $priceList),
'stock_list' => $this->prepareChartData($stockDates, $stockList),
'price_dates' => implode("','", $priceDates),
]);
$progress->advance();
}
$progress->finish();
$output->writeln('');
$output->writeln('DONE');
return Command::SUCCESS;
}
private function prepareChartData($set1, $set2): string
{
$data = [];
foreach ($set1 as $key => $value) {
$data[] = ['x' => $value, 'y' => $set2[$key]];
}
$stringData = json_encode($data);
return str_replace(['"x"', '"y"'], ['x', 'y'], $stringData);
}
}

View File

@@ -118,6 +118,66 @@ class Migrate extends Command
]
);
}
if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'Netherlands')->exists()) {
Capsule::table('countries')->insert([
'countryName' => 'Netherlands',
'productsUrl' => 'https://nl.ryobitools.eu/api/product-listing/get-products',
'cultureCode' => 'nl-NL',
'currency' => 'EUR',
'locale' => 'nl',
'created_at' => now(),
'updated_at' => now(),
]
);
}
if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'France')->exists()) {
Capsule::table('countries')->insert([
'countryName' => 'France',
'productsUrl' => 'https://fr.ryobitools.eu/api/product-listing/get-products',
'cultureCode' => 'fr-FR',
'currency' => 'EUR',
'locale' => 'fr',
'created_at' => now(),
'updated_at' => now(),
]
);
}
if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'Spain')->exists()) {
Capsule::table('countries')->insert([
'countryName' => 'Spain',
'productsUrl' => 'https://es.ryobitools.eu/api/product-listing/get-products',
'cultureCode' => 'es-ES',
'currency' => 'EUR',
'locale' => 'es',
'created_at' => now(),
'updated_at' => now(),
]
);
}
if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'Poland')->exists()) {
$id = Capsule::table('countries')->insertGetId(
[
'countryName' => 'Poland',
'productsUrl' => 'https://pl.ryobitools.eu/api/product-listing/get-products',
'cultureCode' => 'pl-PL',
'currency' => 'PLN',
'locale' => 'pl',
'created_at' => now(),
'updated_at' => now(),
]);
}
if (Capsule::schema()->hasTable('countries') && !Country::where('countryName', 'UK')->exists()) {
Capsule::table('countries')->insert([
'countryName' => 'UK',
'productsUrl' => 'https://uk.ryobitools.eu/api/product-listing/get-products',
'cultureCode' => 'en-GB',
'currency' => 'GBP',
'locale' => 'uk',
'created_at' => now(),
'updated_at' => now(),
]
);
}
if (!Capsule::schema()->hasColumn('products', 'country_id')) {
Capsule::schema()->table('products', function (Blueprint $table) use ($id) {

View File

@@ -15,11 +15,13 @@ use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(name: 'app:scrape', description: 'Scrape all products from Ryobi website')]
class ScrapeWebsite extends Command
{
const COUNTRY_ID = 'country';
private Client $client;
public function __construct(protected Capsule $database)
@@ -30,30 +32,31 @@ class ScrapeWebsite extends Command
protected function configure(): void
{
$this->client = new Client();
$this->addOption(self::COUNTRY_ID, 'c', InputOption::VALUE_OPTIONAL, 'Country id');
}
public function execute(InputInterface $input, OutputInterface $output): int
{
$countryId = intval($input->getOption(self::COUNTRY_ID));
$output->writeln('Scrape products');
$progress = new ProgressBar($output);
$countries = Country::all();
$countries = Country::all()->when($countryId, fn ($query) => $query->where('id', $countryId));
foreach($countries as $country) {
$output->writeln('Country name: ' . $country->countryName);
$progress->start();
$products = $this->getProducts($country);
$progress = new ProgressBar($output);
$progress->start();
$progress->setMaxSteps(count($products));
foreach ($products as $product) {
$this->saveProduct($product, $country);
$progress->advance();
}
$progress->finish();
$output->writeln('');
$output->writeln('Scrape products - DONE');
$output->writeln('');
$output->writeln("\nScrape products - DONE\n");
}
$output->writeln('Update prices');
$products = Product::all();
$progress = new ProgressBar($output);
$progress->setMaxSteps(count($products));
$progress->start();
foreach($products as $product) {
@@ -95,7 +98,7 @@ class ScrapeWebsite extends Command
$products = array_merge($products, $responseObject->products);
$page++;
$canLoadMore = $responseObject->canLoadMore;
} catch (GuzzleException) {
} catch (GuzzleException $e) {
return $products;
}
} while ($canLoadMore);

View File

@@ -11,7 +11,7 @@ class BaseController extends AbstractController
{
protected Environment $twig;
public function __construct(protected FilesystemAdapter $cache, protected Capsule $database)
public function __construct( protected Capsule $database)
{
}
}

View File

@@ -11,9 +11,6 @@ final class CategoryController extends BaseController
#[Route('/category/{category?}', name: 'app_category')]
public function __invoke(?string $category): Response
{
if($this->cache->getItem('list_category_'.$category)->isHit()) {
return $this->render('productList.html.twig', ['listType' => 'category_'.$category]);
}
/** @var Product[] $products */
$products = Product::with(['price', 'lowestPrice'])

View File

@@ -0,0 +1,40 @@
<?php
namespace Krzysiej\RyobiCrawler\Controller;
use Illuminate\Database\Eloquent\Builder;
use Krzysiej\RyobiCrawler\Models\Country;
use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
final class CountryController extends BaseController
{
#[Route('/country/{countryName?}', name: 'app_country')]
public function __invoke(?string $countryName): Response
{
/** @var Product[] $products */
$products = Product::with(['price', 'lowestPrice', 'country'])
->join('countries', 'countries.id', '=', 'products.country_id')
->where('countryName', $countryName)
->orderByDesc('starred')
->orderByDesc('created_by')
->get();
$country = Country::where('countryName', $countryName)->first();
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'country', 'country' => $country, 'countryStats' => $this->countryStats($countryName)]);
}
private function countryStats(string $country): array
{
$countryProducts = Product::join('countries', 'countries.id', '=', 'products.country_id')
->where('countryName', $country);
$stats = [];
$stats['items'] = $countryProducts->get()->count();
// $stats['items2'] = $countryProducts->dd();
return $stats;
}
}

View File

@@ -13,9 +13,6 @@ final class DiscontinuedController extends BaseController
#[Route('/discontinued', name: 'app_discontinued')]
public function __invoke(): Response
{
if($this->cache->getItem('list_discontinued')->isHit()) {
return $this->render('productList.html.twig', ['listType' => 'discontinued']);
}
$products = Product::where('lastSeen', '<', now()->format('Y-m-d'))
->orderByDesc('starred')

View File

@@ -11,9 +11,6 @@ final class IndexController extends BaseController
#[Route('/', name: 'app_home')]
public function __invoke(): Response
{
if ($this->cache->getItem('list_all')->isHit()) {
return $this->render('productList.html.twig', ['listType' => 'all']);
}
$products = Product::orderByDesc('starred')
->orderByDesc('created_by')
->get();

View File

@@ -13,9 +13,6 @@ final class LowestPriceController extends BaseController
public function __invoke(): Response
{
$listType = 'lowest_price';
if($this->cache->getItem('lowest_price')->isHit()) {
return $this->render('productList.html.twig', ['listType' => $listType]);
}
$products = Product::whereRaw('priceCurrent = priceLowest')
->whereRaw('lastSeen = "'.now()->format('Y-m-d').'"')

View File

@@ -13,9 +13,6 @@ final class NewController extends BaseController
#[Route('/new', name: 'app_new')]
public function __invoke(): Response
{
if($this->cache->getItem('list_new')->isHit()) {
return $this->render('productList.html.twig', ['listType' => 'new']);
}
$date = now()->modify('-30 days')->format('Y-m-d');
$products = Product::where('created_at', '>', $date)
->with(['country', 'stock'])

View File

@@ -19,10 +19,6 @@ final class ProductController extends BaseController
#[Route('/product/{productId<\d+>}', name: 'app_product')]
public function __invoke(int $productId): Response
{
if ($this->cache->getItem('product' . $productId)->isHit()) {
return $this->render('product.html.twig', ['product' => ['id' => $productId]]);
}
$product = Product::with([
'price' => fn($query) => $query->orderBy('created_at', 'desc'),
'stock' => fn($query) => $query->orderBy('created_at', 'desc'),
@@ -32,6 +28,36 @@ final class ProductController extends BaseController
}
$priceList = $product->price()->pluck('price', 'created_at')->mapWithKeys(fn($price, $createdAt) => [explode(' ', $createdAt)[0] => $price])->toArray();
$stockList = $product->stock()->pluck('stock', 'created_at')->mapWithKeys(fn($stock, $createdAt) => [explode(' ', $createdAt)[0] => $stock])->toArray();
ksort($stockList);
ksort($priceList);
return $this->render('product.html.twig', [
'product' => $product,
'price_list' => $this->prepareChartData($priceList),
'stock_list' => $this->prepareChartData($stockList),
'price_dates' => implode("','", $this->dateRange(array_key_first($priceList), array_key_last($priceList))),
]);
}
#[Route('/product/model/{productModel}', name: 'app_product_model')]
public function productModel(string $productModel): Response
{
$product = Product::with([
'price' => fn($query) => $query->orderBy('created_at', 'desc'),
'stock' => fn($query) => $query->orderBy('created_at', 'desc'),
])->where('subTitle', $productModel)->first();
if (null === $product) {
throw $this->createNotFoundException('Product not found');
}
$priceList = $product->price()->pluck('price', 'created_at')->mapWithKeys(fn($price, $createdAt) => [explode(' ', $createdAt)[0] => $price])->toArray();
$stockList = $product->stock()->pluck('stock', 'created_at')->mapWithKeys(fn($stock, $createdAt) => [explode(' ', $createdAt)[0] => $stock])->toArray();
ksort($stockList);
ksort($priceList);
return $this->render('product.html.twig', [
'product' => $product,
'price_list' => $this->prepareChartData($priceList),

View File

@@ -11,10 +11,6 @@ final class PromosController extends BaseController
#[Route('/promos/{promo?}', name: 'app_promos')]
public function __invoke(?string $promo): Response
{
if ($this->cache->getItem('list_promos')->isHit()) {
return $this->render('productList.html.twig', ['listType' => 'promos' . $promo]);
}
$products = Product::when(is_null($promo), fn($q) => $q->whereRaw('priceCurrent < productStandardPrice'))
->orderByDesc('starred')
->orderByDesc('created_by')
@@ -24,8 +20,11 @@ final class PromosController extends BaseController
$promos = Product::select($this->database->getConnection()->raw("distinct json_extract(promotions, '$.slug') as slug, json_extract(promotions, '$.tag') as tag"))
->addSelect('countries.locale')
->whereRaw("json_extract(promotions, '$.tag') is not null")
->get();
->join('countries', 'products.country_id', '=', 'countries.id')
->get()
->groupBy('locale');
return $this->render('productList.html.twig', ['products' => $products, 'listType' => 'promos' . $promo, 'promos' => $promos->toArray()]);
}

View File

@@ -12,15 +12,12 @@ final class StarController extends BaseController
#[Route('/star/{productId<\d+>}', name: 'app_star')]
public function __invoke(int $productId, Request $request): Response
{
$this->cache->deleteItems(['list_all', 'list_promos', 'list_new', 'list_discontinued']);
$referer = $request->headers->get('referer');
if (str_contains($referer, '/category/')) {
preg_match('#/category/(.*)#i', $referer, $matches);
$this->cache->deleteItem('list_category_'.urldecode($matches[1]));
}
if (str_contains($referer, '/search?search=')) {
preg_match('#/search\?search=(.*)#i', $referer, $matches);
$this->cache->deleteItem('list_search_'.urldecode($matches[1]));
}
Product::find($productId)->toggleStarred()->save();

View File

@@ -0,0 +1,18 @@
<?php
namespace Krzysiej\RyobiCrawler\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
final class UpdateController extends BaseController
{
#[Route('/update', name: 'app_update')]
public function __invoke(Request $request): Response
{
$output = shell_exec('bin/update');
return new Response($output);
}
}

View File

@@ -38,12 +38,7 @@ class Kernel extends BaseKernel
$services->set(Manager::class)->configurator([DatabaseFactory::class, 'create']);
$services->load('Krzysiej\\RyobiCrawler\\', __DIR__ )
->exclude('../src/{Models,Twig,DatabaseFactory.php,Kernel.php}');
$services->set('twig.extension.cache', AppExtension::class)->tag('twig.extension');
$services->set(CacheExtension::class)->tag('twig.extension');
$services->set(FilesystemAdapter::class)->args([
'$directory' => __DIR__ . '/../var/cache/twig_blocks'
]);
$services->set('twig.runtime.cache', CacheRuntime::class)->args([new Reference(FilesystemAdapter::class)])->tag('twig.runtime');
$services->set('twig.extension', AppExtension::class)->tag('twig.extension');
}
protected function configureRoutes(RoutingConfigurator $routes): void

View File

@@ -3,6 +3,7 @@
namespace Krzysiej\RyobiCrawler\Twig;
use Illuminate\Database\Eloquent\Collection;
use Krzysiej\RyobiCrawler\Models\Country;
use Krzysiej\RyobiCrawler\Models\Price;
use Krzysiej\RyobiCrawler\Models\Product;
use Krzysiej\RyobiCrawler\Models\Stock;
@@ -28,6 +29,7 @@ class AppExtension extends AbstractExtension
new TwigFunction('discontinuedCount', [$this, 'discontinuedCount']),
new TwigFunction('lowestPriceCount', [$this, 'lowestPriceCount']),
new TwigFunction('renderCategoryTree', [$this, 'renderCategoryTree']),
new TwigFunction('getCountries', [$this, 'getCountries']),
];
}
@@ -66,6 +68,11 @@ class AppExtension extends AbstractExtension
->count();
}
public function getCountries(): array
{
return Country::get()->toArray();
}
public function findByCreatedAtDate(Collection $items, string $date): Stock|Price|null
{
return $items->first(fn($item) => str_starts_with($item->created_at, $date));

View File

@@ -1,24 +1,30 @@
{% extends "template.html.twig" %}
{% block content %}
{% cache 'product' ~ product.id %}
<div class="table-responsive">
<table class='table table-hover'>
<tr>
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none"
href="{{ path('app_star', {'productId': product.id}) }}">{% if product.starred %}{% else %}{% endif %}</a></td>
href="{{ path('app_star', {'productId': product.id}) }}">{% if product.starred %}{% else %}{% endif %}</a>
</td>
<td><img src='{{ product.image }}&width=150' class='border rounded p-1' alt='{{ product.name }}'/></td>
<td>
<a href='{{ path('app_product', {'productId': product.id}) }}' class="text-decoration-none">{{ product.name }}</a>
<span class="badge text-bg-light"><a href="{{ path('app_search', {'search': product.subTitle}) }}" class="link-underline link-underline-opacity-0 link-dark">{{ product.subTitle }}</a></span>
{% if product.promotions is not null and product.promotions.hasPromotion %}<a href="{{ path('app_promos', {'promo': product.promotions.slug}) }}"><span class="badge bg-info">PROMO: {{ product.promotions.tag }}</span></a>{% endif %}
<a href='{{ path('app_product', {'productId': product.id}) }}'
class="text-decoration-none">{{ product.name }}</a>
<span class="badge text-bg-light"><a href="{{ path('app_product_model', {'productModel': product.subTitle}) }}"
class="link-underline link-underline-opacity-0 link-dark">{{ product.subTitle }}</a></span>
{% if product.promotions is not null and product.promotions.hasPromotion %}<a
href="{{ path('app_promos', {'promo': product.promotions.slug}) }}"><span class="badge bg-info">PROMO: {{ product.promotions.tag }}</span>
</a>{% endif %}
</td>
<td>
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';">
<ol class="breadcrumb">
{% for category in product.categories %}
<li class="breadcrumb-item" aria-current="page"><a class="breadcrumb-item text-decoration-none"
href="{{ path('app_category', {'category': category}) }}">{{ category }}</a></li>
<li class="breadcrumb-item" aria-current="page"><a
class="breadcrumb-item text-decoration-none"
href="{{ path('app_category', {'category': category}) }}">{{ category }}</a>
</li>
{% endfor %}
</ol>
</nav>
@@ -133,6 +139,5 @@
}
});
</script>
{% endcache %}
{% endblock %}

View File

@@ -1,18 +1,30 @@
{% extends "template.html.twig" %}
{% block content %}
{% cache 'list_' ~ listType %}
{% if listType starts with 'category_' %}
{{ renderCategoryTree(categoryTree, category) | raw }}
{% endif %}
{% if listType starts with 'promos' %}
{% for promo in promos %}
<a href="{{ path('app_promos', {'promo': promo.slug}) }}"><span class="badge bg-info">PROMO: {{ promo.tag }}</span></a>
{% endfor %}
<ul class="list-group list-group-flush">
{% for locale, promoByLocale in promos %}
<li class="list-group-item">
<h5 class="d-inline-block"><span class="badge bg-info">{{ locale | upper }}</span></h5>
{% for promo in promoByLocale %}
<a href="{{ path('app_promos', {'promo': promo.slug}) }}"><span
class="badge bg-info">PROMO: {{ promo.tag }} [{{ promo.locale | upper }}]</span></a>
{% endfor %}
</li>
{% endfor %}
</ul>
{% endif %}
{% if listType == 'country' and country is not null%}
<h2 class="text-muted mt-4 mx-4">{{ country.countryName }}</h2>
<h5 class="mx-4 my-0">Currency: {{ country.currency }}</h5>
{{ dump(countryStats) }}
{% endif %}
{% if (listType starts with 'category_' and category == null) or not (listType starts with 'category_') or (listType starts with 'category_' and category is not null) %}
<div class="table-responsive">
@@ -40,22 +52,24 @@
<td class="align-middle">
<a href='{{ path('app_product', {'productId': product.id}) }}'
class="text-decoration-none">{{ product.name }}</a>
<br>
{% if product.stock > 0 %}
<span class="badge text-bg-light">stock: {{ product.stock }}</span>
{% else %}
<span class="badge text-bg-warning">out of stock</span>
{% endif %}
{% if product.isDiscontinued() %}
<span class="badge text-bg-secondary" data-bs-toggle="tooltip"
data-bs-title="Last update: {{ product.lastSeen }}">is discontinued</span>
<a href="{{ path('app_discontinued') }}"><span class="badge text-bg-secondary" data-bs-toggle="tooltip"
data-bs-title="Last update: {{ product.lastSeen }}">is discontinued</span></a>
{% endif %}
{% if product.isNew() %}
<span class="badge text-bg-success">is new</span>
<a href="{{ path('app_new') }}"><span class="badge text-bg-success">is new</span></a>
{% endif %}
<span class="badge text-bg-light"><a
href="{{ path('app_search', {'search': product.subTitle}) }}"
href="{{ path('app_product_model', {'productModel': product.subTitle}) }}"
class="link-underline link-underline-opacity-0 link-dark">{{ product.subTitle }}</a></span>
{% if product.promotions is not null and product.promotions.hasPromotion %}<a href="{{ path('app_promos', {'promo': product.promotions.slug}) }}"><span class="badge bg-info">PROMO: {{ product.promotions.tag }}</span></a>{% endif %}
<span class="badge text-bg-light"><a href="{{ path('app_country', {'countryName': product.country.countryName}) }}" class="link-underline link-underline-opacity-0 link-dark">{{ product.country.countryName }}</a></span>
</td>
<td class="align-middle">
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';">
@@ -75,7 +89,7 @@
{{ product.priceLowest | format_currency(product.country.currency, {}, product.country.locale) }}
{% else %}
{% if product.priceLowest != product.priceCurrent %}{{ product.priceLowest | format_currency(product.country.currency, {}, product.country.locale) }}{% else %}
<span class="badge text-bg-info">now lowest</span>{% endif %}</td>
<a href="{{ path('app_lowest_price') }}"><span class="badge bg-info">now lowest</span></a>{% endif %}</td>
{% endif %}
<td class="align-middle text-end">{{ product.priceCurrent | format_currency(product.country.currency, {}, product.country.locale) }}</td>
@@ -93,5 +107,4 @@
</table>
</div>
{% endif %}
{% endcache %}
{% endblock %}

View File

@@ -18,7 +18,6 @@
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
{% cache "menu_count" ~ listType|default('') %}
<li class="nav-item">
<a class="nav-link {% if app.request.pathinfo == path('app_home') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_home') }}">All products <span class="badge text-bg-secondary">{{ allCount() }}</span></a>
</li>
@@ -34,7 +33,16 @@
<li class="nav-item">
<a class="nav-link {% if app.request.pathinfo == path('app_discontinued') %}active shadow-sm bg-body rounded{% endif %}" aria-current="page" href="{{ path('app_discontinued') }}">Discontinued <span class="badge text-bg-secondary">{{ discontinuedCount() }}</span></a>
</li>
{% endcache %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Countries
</a>
<ul class="dropdown-menu">
{% for country in getCountries() %}
<li><a class="dropdown-item" href="{{ path('app_country', {'countryName': country.countryName}) }}">{{ country.countryName }}</a></li>
{% endfor %}
</ul>
</li>
</ul>
<form class="form-floating d-flex col-lg-6 col-sm-8" role="search" action="{{ path('app_search') }}">