Skip to content

Commit 29c3b26

Browse files
committed
magento/adobe-stock-integration#1724: Support batches processing for synchronization queue messages - implemented gallery synchronization functionality
1 parent a550e1e commit 29c3b26

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

app/code/Magento/MediaContentSynchronization/Model/Consume.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\MediaContentSynchronization\Model;
99

1010
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\MediaContentApi\Api\Data\ContentIdentityInterface;
1112
use Magento\MediaContentSynchronizationApi\Api\SynchronizeIdentitiesInterface;
1213
use Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface;
1314

@@ -40,15 +41,15 @@ public function __construct(
4041

4142
/**
4243
* Run media files synchronization.
43-
* @param string[] $message
44+
* @param string[] $identities
4445
* @throws LocalizedException
4546
*/
46-
public function execute(array $message) : void
47+
public function execute(array $identities) : void
4748
{
48-
$this->synchronize->execute();
49-
50-
if (!empty($message)) {
51-
$this->synchronizeIdentities->execute($message);
49+
if (!empty($identities)) {
50+
$this->synchronizeIdentities->execute($identities);
51+
} else {
52+
$this->synchronize->execute();
5253
}
5354
}
5455
}

app/code/Magento/MediaContentSynchronization/Model/Publish.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ public function __construct(PublisherInterface $publisher)
3434

3535
/**
3636
* Publish media content synchronization message to the message queue.
37+
* @param array $contentIdentities
3738
*/
38-
public function execute() : void
39+
public function execute(array $contentIdentities = []) : void
3940
{
4041
$this->publisher->publish(
4142
self::TOPIC_MEDIA_CONTENT_SYNCHRONIZATION,
42-
[self::TOPIC_MEDIA_CONTENT_SYNCHRONIZATION]
43+
$contentIdentities
4344
);
4445
}
4546
}

app/code/Magento/MediaContentSynchronization/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
99
<preference for="Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface" type="Magento\MediaContentSynchronization\Model\Synchronize"/>
10+
<preference for="Magento\MediaContentSynchronizationApi\Api\SynchronizeIdentitiesInterface" type="Magento\MediaContentSynchronization\Model\SynchronizeIdentities"/>
1011
<type name="Magento\Framework\Console\CommandListInterface">
1112
<arguments>
1213
<argument name="commands" xsi:type="array">

app/code/Magento/MediaGallerySynchronization/Model/Consume.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ public function __construct(
4040

4141
/**
4242
* Run media files synchronization.
43-
* @param string[] $message
43+
* @param array $paths
4444
* @throws LocalizedException
4545
*/
46-
public function execute(array $message) : void
46+
public function execute(array $paths) : void
4747
{
48-
$this->synchronize->execute();
49-
50-
if (!empty($message)) {
51-
$this->synchronizeFiles->execute($message);
48+
if (!empty($paths)) {
49+
$this->synchronizeFiles->execute($paths);
50+
} else {
51+
$this->synchronize->execute();
5252
}
5353
}
5454
}

app/code/Magento/MediaGallerySynchronization/Model/Publish.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ public function __construct(PublisherInterface $publisher)
3434

3535
/**
3636
* Publish media content synchronization message to the message queue.
37+
* @param array $paths
3738
*/
38-
public function execute() : void
39+
public function execute(array $paths = []) : void
3940
{
4041
$this->publisher->publish(
4142
self::TOPIC_MEDIA_GALLERY_SYNCHRONIZATION,
42-
[self::TOPIC_MEDIA_GALLERY_SYNCHRONIZATION]
43+
$paths
4344
);
4445
}
4546
}

0 commit comments

Comments
 (0)