forked from shopware/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEXT-32330 - Implement first example of new event-based extension sys…
…tem for product listing loader
- Loading branch information
1 parent
88768d7
commit e5e4e99
Showing
14 changed files
with
493 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Core/Content/Product/Extension/ResolveListingExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Shopware\Core\Content\Product\Extension; | ||
|
||
use Shopware\Core\Content\Product\ProductCollection; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\EntitySearchResult; | ||
use Shopware\Core\Framework\Extensions\Extension; | ||
use Shopware\Core\Framework\Log\Package; | ||
use Shopware\Core\System\SalesChannel\SalesChannelContext; | ||
|
||
/** | ||
* @extends Extension<EntitySearchResult<ProductCollection>> | ||
*/ | ||
#[Package('inventory')] | ||
final class ResolveListingExtension extends Extension | ||
{ | ||
public const NAME = 'listing-loader.resolve'; | ||
|
||
/** | ||
* @internal shopware owns the __constructor, but the properties are public API | ||
*/ | ||
public function __construct( | ||
/** | ||
* @public | ||
* | ||
* @description The criteria which should be used to load the products. Is also containing the selected customer filter | ||
*/ | ||
public readonly Criteria $criteria, | ||
/** | ||
* @public | ||
* | ||
* @description Allows you to access to the current customer/sales-channel context | ||
*/ | ||
public readonly SalesChannelContext $context | ||
) { | ||
} | ||
|
||
public static function name(): string | ||
{ | ||
return self::NAME; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/Core/Content/Product/Extension/ResolveListingIdsExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Shopware\Core\Content\Product\Extension; | ||
|
||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\IdSearchResult; | ||
use Shopware\Core\Framework\Extensions\Extension; | ||
use Shopware\Core\Framework\Log\Package; | ||
use Shopware\Core\System\SalesChannel\SalesChannelContext; | ||
|
||
/** | ||
* @public this class is used as type-hint for all event listeners, so the class string is "public consumable" API | ||
* | ||
* @title Determination of the listing product ids | ||
* | ||
* @description This event allows intercepting the listing process, when the product ids should be determined for the current category page and the applied filter. | ||
* | ||
* @extends Extension<IdSearchResult> | ||
*/ | ||
#[Package('inventory')] | ||
final class ResolveListingIdsExtension extends Extension | ||
{ | ||
public const NAME = 'listing-loader.resolve-listing-ids'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function name(): string | ||
{ | ||
return self::NAME; | ||
} | ||
|
||
/** | ||
* @internal shopware owns the __constructor, but the properties are public API | ||
*/ | ||
public function __construct( | ||
/** | ||
* @public | ||
* | ||
* @description The criteria which should be used to load the product ids. Is also containing the selected customer filter | ||
*/ | ||
public Criteria $criteria, | ||
|
||
/** | ||
* @public | ||
* | ||
* @description Allows you to access to the current customer/sales-channel context | ||
*/ | ||
public SalesChannelContext $context | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.