hey @tobiasfabian,
thank you for your reply!
yes, this is the exception i get. but the details.exception is empty.
actually, i am nesting virtual pages, these are my models:
there are different pages for different “seasons”. from a spreadsheet, virtual pages for the fabrics the products are made of are created. the model season.php
is:
<?php
class SeasonPage extends Page
{
public function children()
{
$csv = csv($this->kirby()->root() . '/products.csv', ';');
$children = [];
foreach ($csv as $product) {
if ($this->slug() === $product['hauptsaison']) {
$children[] = [
'slug' => Str::slug($product['vkfarb']),
'template' => 'fabric',
'model' => 'fabric',
'children' => [],
'num' => 0,
'content' => [
'title' => $product['vkfarb'],
]
];
}
}
return Pages::factory($children, $this);
}
}
inside the fabrics pages, the product pages are generated. the model fabric.php
is:
<?php
class FabricPage extends Page
{
public function subpages()
{
return Pages::factory($this->inventory()['children'], $this);
}
public function children()
{
$csv = csv($this->kirby()->root() . '/products.csv', ';');
$children = [];
foreach ($csv as $product) {
$slug = Str::slug($product['product_name']);
$page = $this->subpages()->find($slug);
if ($this->parent()->slug() === $product['hauptsaison'] && $this->title()->toString() === $product['vkfarb']) {
$children[] = [
'slug' => Str::slug($product['product_name']),
'template' => 'variable',
'model' => 'variable',
'children' => $page ? $page->children()->toArray() : null,
'files' => $page ? $page->files()->toArray() : null,
'num' => 0,
'content' => [
'title' => $product['product_name'],
'sku' => $product['sku'],
'simples_skus' => $product['simples_skus'],
'body' => $product['materialzusammensetzung'],
'lining' => $product['futter'],
'price' => $product['price'],
'style' => $product['artikelgruppe'],
'isinstock' => $product['is_in_stock'],
'cover' => $page ? $page->cover()->toArray() : null,
'gallery' => $page ? $page->gallery()->toArray() : null,
'saleprice' => $page ? $page->saleprice()->value() : null,
'goeswellwith' => $page ? $page->goeswellwith()->value() : null,
'hidden' => $page ? $page->hidden()->value() : null,
'description' => $page ? $page->description()->value() : null,
]
];
}
}
return Pages::factory($children, $this);
}
}
and inside the product pages, the variations are generated. the model for variable.php
is:
<?php
class VariablePage extends Page
{
public function subpages()
{
return Pages::factory($this->inventory()['children'], $this);
}
public function zip()
{
return F::unzip($this->kirby()->root() . '/lagerbestand.zip', $this->kirby()->root());
}
public function children()
{
$this->zip();
$csv = csv($this->kirby()->root() . '/lagerbestand.csv', ';');
$children = [];
foreach ($csv as $variation) {
$slug = Str::slug($variation['_grkbez']);
$page = $this->subpages()->find($slug);
if (strpos($this->simples_skus(), $variation['sku']) !== false) {
$children[] = [
'slug' => Str::slug($variation['_grkbez']),
'template' => 'product',
'model' => 'product',
'num' => 0,
'content' => [
'title' => $this->title() . ' - ' . str_replace('.', '', $variation['_grkbez']),
'sku' => $variation['sku'],
'price' => $this->price(),
'size' => $variation['_grkbez'],
'stock' => ($page && $page->stock()->value() != $variation['qty']) ? $page->stock()->value() : $variation['qty'],
],
];
}
}
return Pages::factory($children, $this);
}
}
so the id of a product variation in the end will be: {season}/{fabric}/{product name}/{size}.
i hope this makes sense haha. thank you in advance for any help!