Erkläre bei der Produktseiten-Zuordnung, warum ein Modul oder Lizenzartikel keine eigene Seite bekommt
CI Feature / test (push) Successful in 4m11s
Deploy Test / test (push) Successful in 3m55s
Deploy Test / deploy (push) Successful in 33s

Die Auswahl nennt je Eintrag, ob der Shop die Seite zeigen kann (Programm mit Anzeigefreigabe),
und die Fehlermeldung zur eigenen Paketseite nennt den Weg über Pakete oder ein Programm.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-25 16:30:32 +01:00
1 parent 9041afda80
commit 1950dc377b
4 files changed
+51 -5

No files matched your search

+1 -1
View File
@@ -107,7 +107,7 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
], $attributes); ], $attributes);
if ($offer->standalone_bundle && (count($lines) !== 1 || ! $lines[0]['target'] instanceof BundleVersion)) { if ($offer->standalone_bundle && (count($lines) !== 1 || ! $lines[0]['target'] instanceof BundleVersion)) {
throw new DomainRuleException('Ein Angebot mit eigener Paketseite besteht aus genau einer Paketfassung. Wähle eine Paketfassung oder ordne das Angebot der Seite eines Programms zu.'); throw new DomainRuleException('Ein Angebot mit eigener Paketseite besteht aus genau einer Paketfassung (Katalog → Pakete). Für einen Lizenzartikel ordnest du das Angebot der Seite eines Programms zu: Das Programm muss als Programm angelegt und zur Anzeige freigegeben sein, ein Modul genügt nicht.');
} }
$this->assertAttributes($attributes); $this->assertAttributes($attributes);
@@ -286,20 +286,32 @@ private function productPages(): array
{ {
$catalog = app(PublicCatalogReader::class); $catalog = app(PublicCatalogReader::class);
return [self::OWN_BUNDLE_PAGE => 'Eigene Paketseite · zeigt den Umfang des Pakets (nur für ein Angebot aus genau einer Paketfassung)'] + Composition::query() return [self::OWN_BUNDLE_PAGE => 'Eigene Paketseite · nur für ein Angebot aus genau einer Paketfassung (Katalog → Pakete), nicht für einen Lizenzartikel'] + Composition::query()
->with('editorialContentKind') ->with('editorialContentKind')
->whereNull('archived_at') ->whereNull('archived_at')
->orderBy('designation') ->orderBy('designation')
->get() ->get()
->sortBy(fn (Composition $composition): int => $catalog->shownVersion($composition) !== null ? 0 : 1) ->sortBy(fn (Composition $composition): int => $catalog->shownVersion($composition) !== null ? 0 : (in_array($composition->editorialContentKind?->slug, PublicCatalogReader::PUBLIC_KINDS, true) ? 1 : 2))
->mapWithKeys(fn (Composition $composition): array => [ ->mapWithKeys(fn (Composition $composition): array => [
$composition->id => ($composition->display_title ?: $composition->designation) $composition->id => ($composition->display_title ?: $composition->designation)
.' ('.($composition->editorialContentKind?->label ?? 'Zusammenstellung').')' .' ('.($composition->editorialContentKind?->label ?? 'Zusammenstellung').')'
.($catalog->shownVersion($composition) !== null ? ' · im Shop auffindbar' : ' · nicht öffentlich, im Shop nicht auffindbar'), .self::pageHint($catalog, $composition),
]) ])
->all(); ->all();
} }
/** Sagt bei jeder Auswahl, ob die Seite im Shop auffindbar ist und was fehlt, wenn nicht. */
private static function pageHint(PublicCatalogReader $catalog, Composition $composition): string
{
if ($catalog->shownVersion($composition) !== null) {
return ' · im Shop auffindbar';
}
return in_array($composition->editorialContentKind?->slug, PublicCatalogReader::PUBLIC_KINDS, true)
? ' · noch nicht zur Anzeige freigegeben, im Shop nicht auffindbar'
: ' · kein Programm, im Shop nicht auffindbar (der Shop zeigt nur Programme)';
}
/** /**
* Vorbelegung aus der aktiven Fassung; ohne aktive Fassung eine leere Position. * Vorbelegung aus der aktiven Fassung; ohne aktive Fassung eine leere Position.
* *
@@ -277,7 +277,7 @@ public function forOffer(Offer $offer): array
? 'Eigene Paketseite: Sie zeigt den Umfang des Pakets. Optionen desselben Pakets sind Alternativen im Warenkorb.' ? 'Eigene Paketseite: Sie zeigt den Umfang des Pakets. Optionen desselben Pakets sind Alternativen im Warenkorb.'
: ($page !== null : ($page !== null
? 'Zugeordnet: „'.$pageName.'“. Optionen derselben Produktseite sind Alternativen im Warenkorb.' ? 'Zugeordnet: „'.$pageName.'“. Optionen derselben Produktseite sind Alternativen im Warenkorb.'
: 'Der Shop zeigt ein Angebot auf der Seite eines Programms. Wähle in der Maske die Produktseite. Ein Paket, das für sich verkauft wird, erhält dort „Eigene Paketseite“ und zeigt seinen Umfang; sonst erscheint es auf der Seite eines fremden Programms.'), : 'Der Shop zeigt ein Angebot auf der Seite eines Programms. Wähle in der Maske die Produktseite. Ein Paket (Katalog → Pakete), das für sich verkauft wird, erhält dort „Eigene Paketseite“ und zeigt seinen Umfang; ein Lizenzartikel braucht dagegen ein Programm, das unter „Programme“ angelegt und zur Anzeige freigegeben ist. Ein Modul kann keine Produktseite sein.'),
'stand' => $own || $page !== null ? 'erledigt' : 'offen', 'stand' => $own || $page !== null ? 'erledigt' : 'offen',
'aktion' => $own || $page !== null ? null : $activate, 'aktion' => $own || $page !== null ? null : $activate,
], ],
@@ -8,6 +8,7 @@
use App\Domain\Catalog\ContentElement; use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialContentKind; use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\OfferService; use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\RightsProfileVersion; use App\Domain\Catalog\RightsProfileVersion;
@@ -240,6 +241,39 @@ private function rights(): RightsProfileVersion
return RightsProfileVersion::query()->orderBy('id')->firstOrFail(); return RightsProfileVersion::query()->orderBy('id')->firstOrFail();
} }
public function test_the_product_page_choices_say_which_ones_the_shop_can_show(): void
{
$hidden = $this->hiddenProgram();
$module = app(ContentService::class)->createComposition('Bündel-Modul');
$module->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'modul')->value('id');
$module->save();
$method = new \ReflectionMethod(ViewOffer::class, 'productPages');
$choices = $method->invoke(app(ViewOffer::class));
$this->assertStringContainsString('nur für ein Angebot aus genau einer Paketfassung', $choices['__paket']);
$this->assertStringContainsString('im Shop auffindbar', $choices[$this->program('Konflikte im Training')->id]);
$this->assertStringContainsString('noch nicht zur Anzeige freigegeben', $choices[$hidden->id]);
$this->assertStringContainsString('kein Programm', $choices[$module->id]);
$this->assertStringContainsString('nur Programme', $choices[$module->id]);
}
public function test_an_own_bundle_page_for_a_licence_article_is_refused_with_the_way_forward(): void
{
$offer = app(OfferService::class)->create('Bündel als Artikel');
app(OfferService::class)->assignProduct($offer, null, null, true);
try {
app(OfferService::class)->activate($offer->refresh(), [['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 3900, 'holder_kind' => 'person']);
$this->fail('Ein Lizenzartikel darf keine eigene Paketseite bekommen.');
} catch (DomainRuleException $e) {
$this->assertStringContainsString('Katalog → Pakete', $e->getMessage());
$this->assertStringContainsString('Programm', $e->getMessage());
}
$this->assertSame(0, $offer->versions()->count());
}
private function hiddenProgram(): Composition private function hiddenProgram(): Composition
{ {
$composition = app(ContentService::class)->createComposition('Unveröffentlichtes Programm'); $composition = app(ContentService::class)->createComposition('Unveröffentlichtes Programm');