1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
5
|
|
|
* Use of this software requires acceptance of the Spryker Marketplace License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Spryker\Zed\MerchantProduct\Communication\Plugin\Publisher; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\MerchantProductCriteriaTransfer; |
11
|
|
|
use Spryker\Shared\MerchantProduct\MerchantProductConfig; |
12
|
|
|
use Spryker\Zed\Kernel\Communication\AbstractPlugin; |
13
|
|
|
use Spryker\Zed\PublisherExtension\Dependency\Plugin\PublisherPluginInterface; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @method \Spryker\Zed\MerchantProduct\Business\MerchantProductFacadeInterface getFacade() |
17
|
|
|
* @method \Spryker\Zed\MerchantProduct\Communication\MerchantProductCommunicationFactory getFactory() |
18
|
|
|
* @method \Spryker\Zed\MerchantProduct\Business\MerchantProductBusinessFactory getBusinessFactory() |
19
|
|
|
* @method \Spryker\Zed\MerchantProduct\MerchantProductConfig getConfig() |
20
|
|
|
*/ |
21
|
|
|
class MerchantProductPublisherPlugin extends AbstractPlugin implements PublisherPluginInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* {@inheritDoc} |
25
|
|
|
* |
26
|
|
|
* - Extracts Merchant IDs from event entity transfers. |
27
|
|
|
* - Retrieves product abstract IDs related to these merchants. |
28
|
|
|
* - Triggers product abstract events to rebuild merchant product abstracts after merchant changes. |
29
|
|
|
* |
30
|
|
|
* @api |
31
|
|
|
* |
32
|
|
|
* @param array<\Generated\Shared\Transfer\EventEntityTransfer> $eventEntityTransfers |
33
|
|
|
* @param string $eventName |
34
|
|
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
public function handleBulk(array $eventEntityTransfers, $eventName): void |
38
|
|
|
{ |
39
|
|
|
$this->getBusinessFactory()->createProductEventTrigger()->trigger( |
40
|
|
|
(new MerchantProductCriteriaTransfer()) |
41
|
|
|
->setMerchantIds( |
42
|
|
|
$this->getFactory()->getEventBehaviorFacade()->getEventTransferIds($eventEntityTransfers), |
43
|
|
|
), |
44
|
|
|
); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* {@inheritDoc} |
49
|
|
|
* |
50
|
|
|
* @api |
51
|
|
|
* |
52
|
|
|
* @return array<string> |
53
|
|
|
*/ |
54
|
|
|
public function getSubscribedEvents(): array |
55
|
|
|
{ |
56
|
|
|
return [ |
57
|
|
|
MerchantProductConfig::MERCHANT_PUBLISH, |
58
|
|
|
MerchantProductConfig::ENTITY_SPY_MERCHANT_UPDATE, |
59
|
|
|
]; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|