Skip to content

Commit

Permalink
Refactor the code, PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand-soprex committed Aug 5, 2024
1 parent 1ca5a0d commit 9e74d0b
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Nosto\NostoIntegration\Model\ConfigProvider;
use Nosto\NostoIntegration\Traits\SearchResultHelper;
use Nosto\NostoIntegration\Utils\SearchHelper;
use Psr\Log\LoggerInterface;
use Shopware\Core\Content\Product\Aggregate\ProductVisibility\ProductVisibilityDefinition;
use Shopware\Core\Content\Product\Events\ProductSearchResultEvent;
use Shopware\Core\Content\Product\ProductEvents;
Expand Down Expand Up @@ -40,6 +41,7 @@ public function __construct(
private readonly SalesChannelRepository $salesChannelProductRepository,
private readonly CompositeListingProcessor $listingProcessor,
private readonly ConfigProvider $configProvider,
private readonly LoggerInterface $logger
)
{
}
Expand Down Expand Up @@ -88,8 +90,17 @@ public function load(

$this->listingProcessor->process($request, $productListing, $context);

$this->eventDispatcher->dispatch(
new ProductSearchResultEvent($request, $productListing, $context),
ProductEvents::PRODUCT_SEARCH_RESULT
);

return new ProductSearchRouteResponse($productListing);
} catch (Exception) {
} catch (RoutingException $e) {
$this->logger->error('Routing exception occurred: ' . $e->getMessage());
return $this->decorated->load($request, $context, $criteria);
} catch (Exception $e) {
$this->logger->error('An unexpected error occurred: ' . $e->getMessage());
return $this->decorated->load($request, $context, $criteria);
}
}
Expand Down

0 comments on commit 9e74d0b

Please sign in to comment.