Skip to content

Commit

Permalink
FFWEB-3138: Fix SSR problem for category pages
Browse files Browse the repository at this point in the history
- Fix SSR problem for category pages
- Fix Shopware download export issue
  • Loading branch information
Rayn93 committed Aug 8, 2024
1 parent 8eaa5ea commit 0eea3f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
## Unreleased
### Fix
- Remove uasort() deprecation for CMS export
- Fix SSR problem for category pages
- Fix Shopware download export issue

## [v5.2.0] - 2024.07.12
### Add
- Add userId for cart tracking
Expand Down
14 changes: 9 additions & 5 deletions src/Subscriber/CategoryPageResponseSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Event\BeforeSendResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -50,18 +51,21 @@ public function __construct(
public static function getSubscribedEvents()
{
return [
BeforeSendResponseEvent::class => 'onPageRendered',
KernelEvents::RESPONSE => 'onPageRendered',
];
}

public function onPageRendered(BeforeSendResponseEvent $event): void
public function onPageRendered(ResponseEvent $event): void
{
$request = $event->getRequest();
$response = $event->getResponse();
$categoryPath = $this->getCategoryPath($request);

if (
$this->config->isSsrActive() === false
if ($response->getContent() === false) {
return;
}

if ($this->config->isSsrActive() === false
|| $request->isXmlHttpRequest()
|| $categoryPath === ''
) {
Expand Down

0 comments on commit 0eea3f7

Please sign in to comment.