From c574b0359f4a1bad5a73de7d9b2c395b0aed7113 Mon Sep 17 00:00:00 2001 From: "anton.karunarathne" Date: Fri, 19 Jan 2024 11:55:23 +1030 Subject: [PATCH 1/5] BEG-137: Move recaching to queue consumer changes --- ...derRecachingManagementRequestInterface.php | 61 ++++++++++++++++++ Api/PrerenderRecachingManagementInterface.php | 24 +++++++ .../PrerenderRecachingManagementRequest.php | 63 +++++++++++++++++++ Model/Api/PrerenderRecachingManagement.php | 63 +++++++++++++++++++ Model/Indexer/Category/CategoryIndexer.php | 41 ++++++------ Model/Indexer/Category/ProductIndexer.php | 42 +++++-------- Model/Indexer/Product/ProductIndexer.php | 37 +++++------ etc/communication.xml | 10 +++ etc/di.xml | 4 ++ etc/queue_consumer.xml | 10 +++ etc/queue_publisher.xml | 6 ++ etc/queue_topology.xml | 10 +++ 12 files changed, 303 insertions(+), 68 deletions(-) create mode 100644 Api/Data/PrerenderRecachingManagementRequestInterface.php create mode 100644 Api/PrerenderRecachingManagementInterface.php create mode 100644 Model/Api/Data/PrerenderRecachingManagementRequest.php create mode 100644 Model/Api/PrerenderRecachingManagement.php create mode 100644 etc/communication.xml create mode 100644 etc/queue_consumer.xml create mode 100644 etc/queue_publisher.xml create mode 100644 etc/queue_topology.xml diff --git a/Api/Data/PrerenderRecachingManagementRequestInterface.php b/Api/Data/PrerenderRecachingManagementRequestInterface.php new file mode 100644 index 0000000..a649114 --- /dev/null +++ b/Api/Data/PrerenderRecachingManagementRequestInterface.php @@ -0,0 +1,61 @@ +getData(self::BATCH_URLS); + } + + /** + * @inheritDoc + */ + public function setBatchUrls(string $batchUrls): void + { + $this->setData(self::BATCH_URLS, $batchUrls); + } + + /** + * @inheritDoc + */ + public function getStoreId(): int + { + return $this->getData(self::STORE_ID); + } + + /** + * @inheritDoc + */ + public function setStoreId(int $storeId): void + { + $this->setData(self::STORE_ID, $storeId); + } + + /** + * @inheritDoc + */ + public function getIndexerId(): string + { + return $this->getData(self::INDEXER_ID); + } + + /** + * @inheritDoc + */ + public function setIndexerId(string $indexerId): void + { + $this->setData(self::INDEXER_ID, $indexerId); + } +} diff --git a/Model/Api/PrerenderRecachingManagement.php b/Model/Api/PrerenderRecachingManagement.php new file mode 100644 index 0000000..e7647fb --- /dev/null +++ b/Model/Api/PrerenderRecachingManagement.php @@ -0,0 +1,63 @@ +prerenderClient->recacheUrls( + $this->json->unserialize($prerenderRecachingManagementRequest->getBatchUrls()), + $prerenderRecachingManagementRequest->getStoreId() + ); + $message = 'INFO: Recaching Urls successfully synced for ' . + $prerenderRecachingManagementRequest->getIndexerId(); + } catch (Exception $exception) { + $message = 'ERROR: There was an error syncing the Recaching Urls for ' . + $prerenderRecachingManagementRequest->getIndexerId() . $exception->getMessage(); + } + return $message; + } +} diff --git a/Model/Indexer/Category/CategoryIndexer.php b/Model/Indexer/Category/CategoryIndexer.php index ed04b08..32466d4 100644 --- a/Model/Indexer/Category/CategoryIndexer.php +++ b/Model/Indexer/Category/CategoryIndexer.php @@ -10,6 +10,10 @@ use Aligent\Prerender\Api\PrerenderClientInterface; use Aligent\Prerender\Helper\Config; use Aligent\Prerender\Model\Url\GetUrlsForCategories; +use Aligent\Prerender\Api\Data\PrerenderRecachingManagementRequestInterfaceFactory + as PrerenderRecachingManagementRequest; +use Magento\AsynchronousOperations\Model\MassSchedule; +use Magento\Framework\Serialize\Serializer\Json; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Exception\LocalizedException; @@ -25,42 +29,31 @@ class CategoryIndexer implements IndexerActionInterface, MviewActionInterface, D private const INDEXER_ID = 'prerender_category'; private const DEPLOYMENT_CONFIG_INDEXER_BATCHES = 'indexer/batch_size/'; - /** @var DimensionProviderInterface */ - private DimensionProviderInterface $dimensionProvider; - /** @var GetUrlsForCategories */ - private GetUrlsForCategories $getUrlsForCategories; - /** @var PrerenderClientInterface */ - private PrerenderClientInterface $prerenderClient; - /** @var DeploymentConfig */ - private DeploymentConfig $eploymentConfig; - /** @var Config */ - private Config $prerenderConfigHelper; /** @var int|null */ private ?int $batchSize; /** - * * @param DimensionProviderInterface $dimensionProvider * @param GetUrlsForCategories $getUrlsForCategories * @param PrerenderClientInterface $prerenderClient * @param DeploymentConfig $deploymentConfig * @param Config $prerenderConfigHelper + * @param PrerenderRecachingManagementRequest $prerenderRecachingManagementRequest + * @param MassSchedule $massSchedule * @param int|null $batchSize */ public function __construct( - DimensionProviderInterface $dimensionProvider, - GetUrlsForCategories $getUrlsForCategories, - PrerenderClientInterface $prerenderClient, - DeploymentConfig $deploymentConfig, - Config $prerenderConfigHelper, + private readonly DimensionProviderInterface $dimensionProvider, + private readonly GetUrlsForCategories $getUrlsForCategories, + private readonly PrerenderClientInterface $prerenderClient, + private readonly DeploymentConfig $deploymentConfig, + private readonly Config $prerenderConfigHelper, + private readonly PrerenderRecachingManagementRequest $prerenderRecachingManagementRequest, + private readonly MassSchedule $massSchedule, + private readonly Json $json, ?int $batchSize = 1000 ) { - $this->dimensionProvider = $dimensionProvider; - $this->getUrlsForCategories = $getUrlsForCategories; - $this->prerenderClient = $prerenderClient; - $this->deploymentConfig = $deploymentConfig; $this->batchSize = $batchSize; - $this->prerenderConfigHelper = $prerenderConfigHelper; } /** @@ -147,7 +140,11 @@ public function executeByDimensions(array $dimensions, \Traversable $entityIds): $urlBatches = array_chunk($urls, $this->batchSize); foreach ($urlBatches as $batchUrls) { - $this->prerenderClient->recacheUrls($batchUrls, $storeId); + $request = $this->prerenderRecachingManagementRequest->create(); + $request->setBatchUrls($this->json->serialize($batchUrls)); + $request->setStoreId((int) $storeId); + $request->setIndexerId(self::INDEXER_ID); + $this->massSchedule->publishMass('asynchronous.prerender.recaching', [[$request]]); } } } diff --git a/Model/Indexer/Category/ProductIndexer.php b/Model/Indexer/Category/ProductIndexer.php index f492bc3..24e209a 100644 --- a/Model/Indexer/Category/ProductIndexer.php +++ b/Model/Indexer/Category/ProductIndexer.php @@ -7,10 +7,12 @@ namespace Aligent\Prerender\Model\Indexer\Category; +use Aligent\Prerender\Api\Data\PrerenderRecachingManagementRequestInterfaceFactory as PrerenderRecachingManagementRequest; use Aligent\Prerender\Api\PrerenderClientInterface; use Aligent\Prerender\Helper\Config; use Aligent\Prerender\Model\Indexer\DataProvider\ProductCategories; use Aligent\Prerender\Model\Url\GetUrlsForCategories; +use Magento\AsynchronousOperations\Model\MassSchedule; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Exception\LocalizedException; @@ -19,6 +21,7 @@ use Magento\Framework\Indexer\DimensionalIndexerInterface; use Magento\Framework\Indexer\DimensionProviderInterface; use Magento\Framework\Mview\ActionInterface as MviewActionInterface; +use Magento\Framework\Serialize\Serializer\Json; use Magento\Store\Model\StoreDimensionProvider; class ProductIndexer implements IndexerActionInterface, MviewActionInterface, DimensionalIndexerInterface @@ -26,18 +29,6 @@ class ProductIndexer implements IndexerActionInterface, MviewActionInterface, Di private const INDEXER_ID = 'prerender_category_product'; private const DEPLOYMENT_CONFIG_INDEXER_BATCHES = 'indexer/batch_size/'; - /** @var DimensionProviderInterface */ - private DimensionProviderInterface $dimensionProvider; - /** @var ProductCategories */ - private ProductCategories $productCategoriesDataProvider; - /** @var GetUrlsForCategories */ - private GetUrlsForCategories $getUrlsForCategories; - /** @var PrerenderClientInterface */ - private PrerenderClientInterface $prerenderClient; - /** @var DeploymentConfig */ - private DeploymentConfig $eploymentConfig; - /** @var Config */ - private Config $prerenderConfigHelper; /** @var int|null */ private ?int $batchSize; @@ -52,21 +43,18 @@ class ProductIndexer implements IndexerActionInterface, MviewActionInterface, Di * @param int|null $batchSize */ public function __construct( - DimensionProviderInterface $dimensionProvider, - ProductCategories $productCategoriesDataProvider, - GetUrlsForCategories $getUrlsForCategories, - PrerenderClientInterface $prerenderClient, - DeploymentConfig $deploymentConfig, - Config $prerenderConfigHelper, + private readonly DimensionProviderInterface $dimensionProvider, + private readonly ProductCategories $productCategoriesDataProvider, + private readonly GetUrlsForCategories $getUrlsForCategories, + private readonly PrerenderClientInterface $prerenderClient, + private readonly DeploymentConfig $deploymentConfig, + private readonly Config $prerenderConfigHelper, + private readonly PrerenderRecachingManagementRequest $prerenderRecachingManagementRequest, + private readonly MassSchedule $massSchedule, + private readonly Json $json, ?int $batchSize = 1000 ) { - $this->dimensionProvider = $dimensionProvider; - $this->productCategoriesDataProvider = $productCategoriesDataProvider; - $this->getUrlsForCategories = $getUrlsForCategories; - $this->prerenderClient = $prerenderClient; - $this->deploymentConfig = $deploymentConfig; $this->batchSize = $batchSize; - $this->prerenderConfigHelper = $prerenderConfigHelper; } /** @@ -156,7 +144,11 @@ public function executeByDimensions(array $dimensions, \Traversable $entityIds): $urlBatches = array_chunk($urls, $this->batchSize); foreach ($urlBatches as $batchUrls) { - $this->prerenderClient->recacheUrls($batchUrls, $storeId); + $request = $this->prerenderRecachingManagementRequest->create(); + $request->setBatchUrls($this->json->serialize($batchUrls)); + $request->setStoreId((int) $storeId); + $request->setIndexerId(self::INDEXER_ID); + $this->massSchedule->publishMass('asynchronous.prerender.recaching', [[$request]]); } } } diff --git a/Model/Indexer/Product/ProductIndexer.php b/Model/Indexer/Product/ProductIndexer.php index 209cbd7..438cb2b 100644 --- a/Model/Indexer/Product/ProductIndexer.php +++ b/Model/Indexer/Product/ProductIndexer.php @@ -7,9 +7,11 @@ namespace Aligent\Prerender\Model\Indexer\Product; +use Aligent\Prerender\Api\Data\PrerenderRecachingManagementRequestInterfaceFactory as PrerenderRecachingManagementRequest; use Aligent\Prerender\Api\PrerenderClientInterface; use Aligent\Prerender\Helper\Config; use Aligent\Prerender\Model\Url\GetUrlsForProducts; +use Magento\AsynchronousOperations\Model\MassSchedule; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Exception\LocalizedException; @@ -18,6 +20,7 @@ use Magento\Framework\Indexer\DimensionalIndexerInterface; use Magento\Framework\Indexer\DimensionProviderInterface; use Magento\Framework\Mview\ActionInterface as MviewActionInterface; +use Magento\Framework\Serialize\Serializer\Json; use Magento\Store\Model\StoreDimensionProvider; class ProductIndexer implements IndexerActionInterface, MviewActionInterface, DimensionalIndexerInterface @@ -25,16 +28,6 @@ class ProductIndexer implements IndexerActionInterface, MviewActionInterface, Di private const INDEXER_ID = 'prerender_product'; private const DEPLOYMENT_CONFIG_INDEXER_BATCHES = 'indexer/batch_size/'; - /** @var DimensionProviderInterface */ - private DimensionProviderInterface $dimensionProvider; - /** @var GetUrlsForProducts */ - private GetUrlsForProducts $getUrlsForProducts; - /** @var PrerenderClientInterface */ - private PrerenderClientInterface $prerenderClient; - /** @var DeploymentConfig */ - private DeploymentConfig $eploymentConfig; - /** @var Config */ - private Config $prerenderConfigHelper; /** @var int|null */ private ?int $batchSize; @@ -48,19 +41,17 @@ class ProductIndexer implements IndexerActionInterface, MviewActionInterface, Di * @param int|null $batchSize */ public function __construct( - DimensionProviderInterface $dimensionProvider, - GetUrlsForProducts $getUrlsForProducts, - PrerenderClientInterface $prerenderClient, - DeploymentConfig $deploymentConfig, - Config $prerenderConfigHelper, + private readonly DimensionProviderInterface $dimensionProvider, + private readonly GetUrlsForProducts $getUrlsForProducts, + private readonly PrerenderClientInterface $prerenderClient, + private readonly DeploymentConfig $deploymentConfig, + private readonly Config $prerenderConfigHelper, + private readonly PrerenderRecachingManagementRequest $prerenderRecachingManagementRequest, + private readonly MassSchedule $massSchedule, + private readonly Json $json, ?int $batchSize = 1000 ) { - $this->dimensionProvider = $dimensionProvider; - $this->getUrlsForProducts = $getUrlsForProducts; - $this->prerenderClient = $prerenderClient; - $this->deploymentConfig = $deploymentConfig; $this->batchSize = $batchSize; - $this->prerenderConfigHelper = $prerenderConfigHelper; } /** @@ -147,7 +138,11 @@ public function executeByDimensions(array $dimensions, \Traversable $entityIds): $urlBatches = array_chunk($urls, $this->batchSize); foreach ($urlBatches as $batchUrls) { - $this->prerenderClient->recacheUrls($batchUrls, $storeId); + $request = $this->prerenderRecachingManagementRequest->create(); + $request->setBatchUrls($this->json->serialize($batchUrls)); + $request->setStoreId((int) $storeId); + $request->setIndexerId(self::INDEXER_ID); + $this->massSchedule->publishMass('asynchronous.prerender.recaching', [[$request]]); } } } diff --git a/etc/communication.xml b/etc/communication.xml new file mode 100644 index 0000000..9ca0106 --- /dev/null +++ b/etc/communication.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/etc/di.xml b/etc/di.xml index 765547c..6321ce2 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -7,6 +7,10 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + + diff --git a/etc/queue_consumer.xml b/etc/queue_consumer.xml new file mode 100644 index 0000000..b0b0f10 --- /dev/null +++ b/etc/queue_consumer.xml @@ -0,0 +1,10 @@ + + + + diff --git a/etc/queue_publisher.xml b/etc/queue_publisher.xml new file mode 100644 index 0000000..c2ac266 --- /dev/null +++ b/etc/queue_publisher.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/etc/queue_topology.xml b/etc/queue_topology.xml new file mode 100644 index 0000000..bd53ad1 --- /dev/null +++ b/etc/queue_topology.xml @@ -0,0 +1,10 @@ + + + + + + From 47933ccda5e8fddf61056a0aec9183c234b11e5b Mon Sep 17 00:00:00 2001 From: "anton.karunarathne" Date: Fri, 19 Jan 2024 12:05:43 +1030 Subject: [PATCH 2/5] BEG-137: code refinement changes --- Model/Indexer/Category/CategoryIndexer.php | 4 +++- Model/Indexer/Category/ProductIndexer.php | 7 +++++-- Model/Indexer/Product/ProductIndexer.php | 7 +++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Model/Indexer/Category/CategoryIndexer.php b/Model/Indexer/Category/CategoryIndexer.php index 32466d4..59348b9 100644 --- a/Model/Indexer/Category/CategoryIndexer.php +++ b/Model/Indexer/Category/CategoryIndexer.php @@ -122,7 +122,9 @@ public function execute($ids): void public function executeByDimensions(array $dimensions, \Traversable $entityIds): void { if (count($dimensions) > 1 || !isset($dimensions[StoreDimensionProvider::DIMENSION_NAME])) { - throw new \InvalidArgumentException('Indexer "' . self::INDEXER_ID . '" supports only Store dimension'); + throw new \InvalidArgumentException( + 'Indexer "' . self::INDEXER_ID . '" supports only Store dimension' + ); } $storeId = (int)$dimensions[StoreDimensionProvider::DIMENSION_NAME]->getValue(); diff --git a/Model/Indexer/Category/ProductIndexer.php b/Model/Indexer/Category/ProductIndexer.php index 24e209a..40cc03e 100644 --- a/Model/Indexer/Category/ProductIndexer.php +++ b/Model/Indexer/Category/ProductIndexer.php @@ -7,7 +7,8 @@ namespace Aligent\Prerender\Model\Indexer\Category; -use Aligent\Prerender\Api\Data\PrerenderRecachingManagementRequestInterfaceFactory as PrerenderRecachingManagementRequest; +use Aligent\Prerender\Api\Data\PrerenderRecachingManagementRequestInterfaceFactory + as PrerenderRecachingManagementRequest; use Aligent\Prerender\Api\PrerenderClientInterface; use Aligent\Prerender\Helper\Config; use Aligent\Prerender\Model\Indexer\DataProvider\ProductCategories; @@ -123,7 +124,9 @@ public function execute($ids): void public function executeByDimensions(array $dimensions, \Traversable $entityIds): void { if (count($dimensions) > 1 || !isset($dimensions[StoreDimensionProvider::DIMENSION_NAME])) { - throw new \InvalidArgumentException('Indexer "' . self::INDEXER_ID . '" supports only Store dimension'); + throw new \InvalidArgumentException( + 'Indexer "' . self::INDEXER_ID . '" supports only Store dimension' + ); } $storeId = (int)$dimensions[StoreDimensionProvider::DIMENSION_NAME]->getValue(); diff --git a/Model/Indexer/Product/ProductIndexer.php b/Model/Indexer/Product/ProductIndexer.php index 438cb2b..912ce37 100644 --- a/Model/Indexer/Product/ProductIndexer.php +++ b/Model/Indexer/Product/ProductIndexer.php @@ -7,7 +7,8 @@ namespace Aligent\Prerender\Model\Indexer\Product; -use Aligent\Prerender\Api\Data\PrerenderRecachingManagementRequestInterfaceFactory as PrerenderRecachingManagementRequest; +use Aligent\Prerender\Api\Data\PrerenderRecachingManagementRequestInterfaceFactory + as PrerenderRecachingManagementRequest; use Aligent\Prerender\Api\PrerenderClientInterface; use Aligent\Prerender\Helper\Config; use Aligent\Prerender\Model\Url\GetUrlsForProducts; @@ -120,7 +121,9 @@ public function execute($ids): void public function executeByDimensions(array $dimensions, \Traversable $entityIds): void { if (count($dimensions) > 1 || !isset($dimensions[StoreDimensionProvider::DIMENSION_NAME])) { - throw new \InvalidArgumentException('Indexer "' . self::INDEXER_ID . '" supports only Store dimension'); + throw new \InvalidArgumentException( + 'Indexer "' . self::INDEXER_ID . '" supports only Store dimension' + ); } $storeId = (int)$dimensions[StoreDimensionProvider::DIMENSION_NAME]->getValue(); From 6705f40e51c0ae8a61a265ee0e27a2f405ec07a3 Mon Sep 17 00:00:00 2001 From: "anton.karunarathne" Date: Fri, 19 Jan 2024 15:13:03 +1030 Subject: [PATCH 3/5] BEG-137: code refinement changes --- Model/Api/PrerenderRecachingManagement.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Model/Api/PrerenderRecachingManagement.php b/Model/Api/PrerenderRecachingManagement.php index e7647fb..e55c1fb 100644 --- a/Model/Api/PrerenderRecachingManagement.php +++ b/Model/Api/PrerenderRecachingManagement.php @@ -8,24 +8,11 @@ namespace Aligent\Prerender\Model\Api; -use Magento\Framework\Exception\BulkException; -use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Serialize\Serializer\Json; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; -use Magento\Sales\Api\OrderRepositoryInterface; -use Magento\Sales\Api\Data\OrderInterface; use Aligent\Prerender\Api\PrerenderRecachingManagementInterface; use Aligent\Prerender\Api\Data\PrerenderRecachingManagementRequestInterface; use Aligent\Prerender\Api\PrerenderClientInterface; -use Magento\Sales\Model\Order; use Exception; -use DOMDocument; -use DOMException; -use Magento\Store\Model\App\Emulation; -use Magento\Framework\Escaper; -use Magento\Framework\Stdlib\DateTime\DateTime; -use Magento\Directory\Model\CountryFactory; -use Magento\Framework\Exception\CouldNotSaveException; class PrerenderRecachingManagement implements PrerenderRecachingManagementInterface { From c17b3a32126ae6e73215567d0a69f1db157c04a6 Mon Sep 17 00:00:00 2001 From: "anton.karunarathne" Date: Mon, 22 Jan 2024 09:37:57 +1030 Subject: [PATCH 4/5] BEG-137: PHP 8.1 compatibility changes --- .github/workflows/php.yml | 4 ++-- Helper/Config.php | 9 +++----- .../PrerenderRecachingManagementRequest.php | 2 +- Model/Api/PrerenderClient.php | 21 ++++-------------- Model/Api/PrerenderRecachingManagement.php | 2 +- .../DataProvider/ProductCategories.php | 11 ++-------- Model/Url/GetUrlsForCategories.php | 22 ++++--------------- Model/Url/GetUrlsForProducts.php | 22 ++++--------------- composer.json | 2 +- 9 files changed, 22 insertions(+), 73 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 35e1033..2f3bff7 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,7 +1,7 @@ name: Run PHP Static Analysis on: pull_request - + jobs: code-standards: runs-on: ubuntu-latest @@ -11,7 +11,7 @@ jobs: with: fetch-depth: 0 - name: Code Standards Test - uses: docker://aligent/code-standards-pipe-php:7.4 + uses: docker://aligent/code-standards-pipe-php:8.1 env: STANDARDS: "Magento2" SKIP_DEPENDENCIES: "true" diff --git a/Helper/Config.php b/Helper/Config.php index e669132..4a43e84 100644 --- a/Helper/Config.php +++ b/Helper/Config.php @@ -16,16 +16,13 @@ class Config private const XML_PATH_PRERENDER_TOKEN = 'system/prerender/token'; private const XML_PATH_RECACHE_SERVICE_URL = 'system/prerender/service_url'; - /** @var ScopeConfigInterface */ - private ScopeConfigInterface $scopeConfig; - /** * * @param ScopeConfigInterface $scopeConfig */ - public function __construct(ScopeConfigInterface $scopeConfig) - { - $this->scopeConfig = $scopeConfig; + public function __construct( + private readonly ScopeConfigInterface $scopeConfig + ) { } /** diff --git a/Model/Api/Data/PrerenderRecachingManagementRequest.php b/Model/Api/Data/PrerenderRecachingManagementRequest.php index 4d1745e..527d125 100644 --- a/Model/Api/Data/PrerenderRecachingManagementRequest.php +++ b/Model/Api/Data/PrerenderRecachingManagementRequest.php @@ -1,7 +1,7 @@ prerenderConfigHelper = $prerenderConfigHelper; - $this->jsonSerializer = $jsonSerializer; - $this->logger = $logger; - $this->client = $client; $this->client->addHeader('content-type', 'application/json'); } diff --git a/Model/Api/PrerenderRecachingManagement.php b/Model/Api/PrerenderRecachingManagement.php index e55c1fb..8a0e6c9 100644 --- a/Model/Api/PrerenderRecachingManagement.php +++ b/Model/Api/PrerenderRecachingManagement.php @@ -1,7 +1,7 @@ productCollectionFactory = $productCollectionFactory; - $this->categoryCollectionFactory = $categoryCollectionFactory; } /** diff --git a/Model/Url/GetUrlsForCategories.php b/Model/Url/GetUrlsForCategories.php index e8696d5..27e1b0f 100644 --- a/Model/Url/GetUrlsForCategories.php +++ b/Model/Url/GetUrlsForCategories.php @@ -18,16 +18,6 @@ class GetUrlsForCategories { private const DELIMETER = "?"; - /** @var CollectionFactory */ - private CollectionFactory $categoryCollectionFactory; - /** @var StoreManagerInterface */ - private StoreManagerInterface $storeManager; - /** @var Emulation */ - private Emulation $emulation; - - /** @var Url */ - private Url $url; - /** * * @param CollectionFactory $categoryCollectionFactory @@ -35,15 +25,11 @@ class GetUrlsForCategories * @param Emulation $emulation */ public function __construct( - CollectionFactory $categoryCollectionFactory, - StoreManagerInterface $storeManager, - Emulation $emulation, - Url $url + private readonly CollectionFactory $categoryCollectionFactory, + private readonly StoreManagerInterface $storeManager, + private readonly Emulation $emulation, + private readonly Url $url ) { - $this->categoryCollectionFactory = $categoryCollectionFactory; - $this->storeManager = $storeManager; - $this->emulation = $emulation; - $this->url = $url; } /** diff --git a/Model/Url/GetUrlsForProducts.php b/Model/Url/GetUrlsForProducts.php index e2ba4b6..e8a6070 100644 --- a/Model/Url/GetUrlsForProducts.php +++ b/Model/Url/GetUrlsForProducts.php @@ -18,16 +18,6 @@ class GetUrlsForProducts { private const DELIMETER = "?"; - /** @var CollectionFactory */ - private CollectionFactory $productCollectionFactory; - /** @var StoreManagerInterface */ - private StoreManagerInterface $storeManager; - /** @var Emulation */ - private Emulation $emulation; - - /** @var Url */ - private Url $url; - /** * * @param CollectionFactory $productCollectionFactory @@ -35,15 +25,11 @@ class GetUrlsForProducts * @param Emulation $emulation */ public function __construct( - CollectionFactory $productCollectionFactory, - StoreManagerInterface $storeManager, - Emulation $emulation, - Url $url + private readonly CollectionFactory $productCollectionFactory, + private readonly StoreManagerInterface $storeManager, + private readonly Emulation $emulation, + private readonly Url $url ) { - $this->productCollectionFactory = $productCollectionFactory; - $this->storeManager = $storeManager; - $this->emulation = $emulation; - $this->url = $url; } /** diff --git a/composer.json b/composer.json index 9725fd5..80c74f2 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "aligent/magento2-prerender", "description": "Prerender service integration for Magento 2, providing recaching for product URLs", "require": { - "php": ">=7.4", + "php": ">=8.1", "magento/framework": "*" }, "require-dev": { From eb5bc3f4fd6742a0faf4122d3d6d1e367e81e796 Mon Sep 17 00:00:00 2001 From: "anton.karunarathne" Date: Wed, 27 Mar 2024 13:57:16 +1030 Subject: [PATCH 5/5] BEG-137: Resolve conflicts --- Model/Indexer/Category/ProductIndexer.php | 3 +++ Model/Indexer/Product/ProductIndexer.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Model/Indexer/Category/ProductIndexer.php b/Model/Indexer/Category/ProductIndexer.php index f6fae03..8010a4b 100644 --- a/Model/Indexer/Category/ProductIndexer.php +++ b/Model/Indexer/Category/ProductIndexer.php @@ -43,6 +43,9 @@ class ProductIndexer implements IndexerActionInterface, MviewActionInterface, Di * @param DeploymentConfig $deploymentConfig * @param Config $prerenderConfigHelper * @param Configurable $configurable + * @param PrerenderRecachingManagementRequest $prerenderRecachingManagementRequest + * @param MassSchedule $massSchedule + * @param Json $json * @param int|null $batchSize */ public function __construct( diff --git a/Model/Indexer/Product/ProductIndexer.php b/Model/Indexer/Product/ProductIndexer.php index fd49a8c..ea15c0c 100644 --- a/Model/Indexer/Product/ProductIndexer.php +++ b/Model/Indexer/Product/ProductIndexer.php @@ -41,6 +41,9 @@ class ProductIndexer implements IndexerActionInterface, MviewActionInterface, Di * @param DeploymentConfig $deploymentConfig * @param Config $prerenderConfigHelper * @param Configurable $configurable + * @param PrerenderRecachingManagementRequest $prerenderRecachingManagementRequest + * @param MassSchedule $massSchedule + * @param Json $json * @param int|null $batchSize */ public function __construct(