239240241242243244245246247248249250251252253254255256257 } else if (count($path) == 4) {
$first = Catalog::getOne($path[0], true);
if (empty($first)) throw new NotFoundHttpException();
$second = $first->getChild($path[1])->one();
if (empty($second)) throw new NotFoundHttpException();
$third = $second->getChild($path[2])->one();
if (empty($third)) throw new NotFoundHttpException();
$id = $path[3];
$product = Products::find()->where(['id' => $id])->one();
$chars = $product->getFilters()->all();
if (empty($product)) throw new NotFoundHttpException();
$canonicalLink = "/catalog/" . $first->dir. "/" . $second->dir . "/" . $third->dir . "/" . $product->id;
if (!empty($product->brand) && $third->is_brand) {
$canonicalLink = preg_replace('/'.$third->dir.'\//', '', $canonicalLink);
}
return $this->render("catalog/product", ['product' => $product, 'chars' => $chars, 'slider' => $product->images('images', 1200, 1200, 'outbound', true), "category" => $first, "category2" => $second, "category3" => $third, 'canonicalLink' => $canonicalLink]);
} else {
throw new NotFoundHttpException();
}