Example #1
0
 /**
  * @param string $path
  */
 public function actionDefault($path)
 {
     $pathsSeparatorPosition = strrpos($path, '/');
     if ($pathsSeparatorPosition !== false) {
         $categoryPath = substr($path, 0, $pathsSeparatorPosition);
         $productPath = substr($path, $pathsSeparatorPosition + 1);
         $productCandidates = $this->productService->getByPath($productPath);
         foreach ($productCandidates as $productCandidate) {
             foreach ($productCandidate->getCategories() as $category) {
                 if ($category->getPath() === $categoryPath) {
                     $this->product = $productCandidate;
                     break 2;
                 }
             }
         }
     }
     if ($this->product === null) {
         throw new BadRequestException(sprintf('Product with path %s not found.', $path));
     }
     $this->setCurrentCategory($category);
 }