Zeige auf der Shopkachel Titelbild, Saeulen, Materialart mit Symbol und Marker
- ShopCatalog als gemeinsame Datenquelle der Kacheln, shop/kachel als Partial - Titelbild nur mit Website-Freigabe (PresentationMedia::coverPresentation), schmueckend mit leerem alt - Symbol je Materialart (Stammdaten), Marker Neu, Aktualisiert, Beliebt mit Einstellung am Artikel - Migration 2026_12_01_100000, rein ergaenzend - ADR-54, Plan, DEPLOYMENT.md Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
db3a6ba779
commit
0ac70884cc
18 files changed
+991
-88
No files matched your search
@@ -2,22 +2,15 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use App\Domain\Commerce\ShopCatalog;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* Durchsuchbarer Shop (Etappe 1): macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite
|
||||
* wie die Programmkacheln. Gelistet wird nur, was zur Anzeige freigegeben ist und mindestens eine kaufbare Option hat.
|
||||
* Durchsuchbarer Shop: macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite wie die
|
||||
* Programmkacheln. Gelistet wird nur, was mindestens eine kaufbare Option hat; die Kacheln bildet ShopCatalog.
|
||||
*/
|
||||
class ShopController extends Controller
|
||||
{
|
||||
@@ -30,79 +23,10 @@ public function closed(): View|RedirectResponse
|
||||
return Shop::checkoutOpen() ? redirect()->route('shop') : view('shop.closed');
|
||||
}
|
||||
|
||||
public function index(Request $request, ProductOptions $products, PublicCatalogReader $catalog): View
|
||||
public function index(Request $request, ShopCatalog $catalog): View
|
||||
{
|
||||
$term = trim((string) $request->query('suche', ''));
|
||||
$summaries = $products->summaries();
|
||||
$cards = [];
|
||||
|
||||
foreach (Composition::query()->whereIn('id', array_keys($summaries))->orderBy('designation')->get() as $composition) {
|
||||
$version = $catalog->shownVersion($composition);
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = (string) ($composition->display_title ?: $composition->designation);
|
||||
$haystack = mb_strtolower($title.' '.$composition->teaser.' '.FormattedText::plain($composition->summary).' '.$composition->search_terms);
|
||||
|
||||
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $summaries[$composition->id];
|
||||
$cards[] = [
|
||||
'url' => route('public.program', $composition),
|
||||
'title' => $title,
|
||||
'teaser' => (string) ($composition->teaser ?: FormattedText::plain($composition->summary)),
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
// Lizenzartikel mit kaufbarer Option: Titel und Kurztext aus der Redaktion des Artikels (sonst seines Inhalts).
|
||||
$articleSummaries = $products->articleSummaries();
|
||||
|
||||
foreach (LicenseArticle::query()->whereIn('id', array_keys($articleSummaries))->whereNull('archived_at')->orderBy('code')->get() as $article) {
|
||||
$profile = app(EditorialProfileReader::class)->read($article, 'kachel');
|
||||
$title = $products->articleTitle($article);
|
||||
$teaser = (string) ($profile->value('teaser') ?: $profile->value('summary'));
|
||||
$haystack = mb_strtolower($title.' '.$teaser.' '.$profile->value('summary').' '.$profile->searchTerms);
|
||||
|
||||
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $articleSummaries[$article->id];
|
||||
$cards[] = [
|
||||
'url' => route('shop.article', $article),
|
||||
'title' => $title,
|
||||
'teaser' => $teaser,
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
// Pakete mit eigener Produktseite: gelistet mit Name und enthaltenen Artikeln.
|
||||
foreach (Bundle::query()->whereIn('id', array_keys($products->bundleSummaries()))->orderBy('name')->get() as $bundle) {
|
||||
$options = $products->forBundle($bundle);
|
||||
$contents = $products->bundleContents($options);
|
||||
$names = implode(', ', array_column($contents, 'title'));
|
||||
|
||||
if ($term !== '' && ! str_contains(mb_strtolower($bundle->name.' '.$names), mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $products->bundleSummaries()[$bundle->id];
|
||||
$cards[] = [
|
||||
'url' => route('public.package', $bundle),
|
||||
'title' => (string) $bundle->name,
|
||||
'teaser' => 'Paket mit '.count($contents).' '.(count($contents) === 1 ? 'Inhalt' : 'Inhalten').($names !== '' ? ': '.$names : ''),
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
return view('shop.index', ['cards' => $cards, 'term' => $term]);
|
||||
return view('shop.index', ['cards' => $catalog->cards($term), 'term' => $term]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user