218219220221222223224225226227228229230231232233234235236 $second = $first->getChild($path[1])->one();
if (empty($second)) throw new NotFoundHttpException();
$third = $second->getChild($path[2])->one();
if (empty($third)) {
$product = Products::find()->where(['id' => $path[2]])->one();
$canonicalLink = "/catalog/" . $first->dir. "/" . $second->dir . "/" . $product->id;
if (!empty($product->brand) && $second->is_brand) {
$canonicalLink = preg_replace('/'.$second->dir.'\//', '', $canonicalLink);
}
$chars = $product->getFilters()->all();
if (empty($product)) throw new NotFoundHttpException();
return $this->render("catalog/product", ['product' => $product, 'chars' => $chars, 'slider' => $product->images('images', 1200, 1200, 'outbound', true), "category" => $first, "category2" => $second, 'canonicalLink' => $canonicalLink]);
}
else {
$link = "/catalog/" . $first->dir. "/" . $second->dir . "/" . $third->dir;
$get = Yii::$app->request->get();
$products = Products::products($get, $link);
$filters = $third->getSubsFilters();
$relatedValue = FiltersValues::getRelatedProds($third->getSubsProducts());