Skip to content

Commit

Permalink
Prevent exception if logged in customer is from another site
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Aug 31, 2022
1 parent 30fdbd4 commit 6ca0345
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/MShop/Common/Manager/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,15 @@ protected function siteInactive( string $current ) : \Aimeos\Map

if( ( $userId = $this->context()->user() ) )
{
$siteId = \Aimeos\MShop::create( $this->context(), 'customer' )->get( $userId )->getSiteId();

$sites = $sites->filter( function( $item ) use ( $siteId ) {
return strncmp( $item, $siteId, strlen( $siteId ) );
} );
$manager = \Aimeos\MShop::create( $this->context(), 'customer' );
$custItems = $manager->search( $manager->filter()->add( ['customer.id' => $userId] ) );

if( $siteId = $custItems->getSiteId()->first() )
{
$sites = $sites->filter( function( $item ) use ( $siteId ) {
return strncmp( $item, $siteId, strlen( $siteId ) );
} );
}
}

self::$siteInactive[$current] = $sites;
Expand Down

0 comments on commit 6ca0345

Please sign in to comment.