Skip to content

Commit e4449fe

Browse files
authored
Merge pull request #847 from pradeepkanaka/ADO-406/fix-class-doesnot-exist-issue
Fix class doesnot exist issue
2 parents af33b7b + d26be56 commit e4449fe

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

app/code/Meta/Catalog/Plugin/FacebookCatalogUpdateFullReindexPlugin.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Magento\Framework\Mview\View;
2626
use Magento\Indexer\Model\WorkingStateProvider;
2727
use Magento\Framework\ObjectManagerInterface;
28+
use Magento\Framework\App\ProductMetadataInterface;
2829

2930
class FacebookCatalogUpdateFullReindexPlugin
3031
{
@@ -48,21 +49,29 @@ class FacebookCatalogUpdateFullReindexPlugin
4849
*/
4950
private $objectManager;
5051

52+
/**
53+
* @var ProductMetadataInterface
54+
*/
55+
private $productMetadataInterface;
56+
5157
/**
5258
* FacebookCatalogUpdateOnIndexerPlugin constructor
5359
*
5460
* @param WorkingStateProvider $workingStateProvider
5561
* @param FBCatalogUpdateResourceModel $fbCatalogUpdateResourceModel
5662
* @param ObjectManagerInterface $objectManager
63+
* @param ProductMetadataInterface $productMetadataInterface
5764
*/
5865
public function __construct(
5966
WorkingStateProvider $workingStateProvider,
6067
FBCatalogUpdateResourceModel $fbCatalogUpdateResourceModel,
61-
ObjectManagerInterface $objectManager
68+
ObjectManagerInterface $objectManager,
69+
ProductMetadataInterface $productMetadataInterface
6270
) {
6371
$this->workingStateProvider = $workingStateProvider;
6472
$this->fbCatalogUpdateResourceModel = $fbCatalogUpdateResourceModel;
6573
$this->objectManager = $objectManager;
74+
$this->productMetadataInterface = $productMetadataInterface;
6675
}
6776

6877
/**
@@ -110,10 +119,10 @@ public function beforeReindexAll(Indexer $subject)
110119
*/
111120
public function getChangelogBatchWalkerInstance()
112121
{
113-
$changeLogWalkerFactory = $this->objectManager->create(
114-
\Magento\Framework\Mview\View\ChangeLogBatchWalkerFactory::class // @phpstan-ignore-line
115-
);
116-
if (get_class($changeLogWalkerFactory) == "ChangeLogBatchWalkerFactory") {
122+
if ($this->isMagentoVersionLessThan("2.4.7")) {
123+
$changeLogWalkerFactory = $this->objectManager->create(
124+
\Magento\Framework\Mview\View\ChangeLogBatchWalkerFactory::class // @phpstan-ignore-line
125+
);
117126
return $changeLogWalkerFactory->create(
118127
\Magento\Framework\Mview\View\ChangeLogBatchWalker::class // @phpstan-ignore-line
119128
);
@@ -127,6 +136,17 @@ public function getChangelogBatchWalkerInstance()
127136
);
128137
}
129138

139+
/**
140+
* Returns true if the version is lower than the expected version
141+
*
142+
* @param $version
143+
* @return bool
144+
*/
145+
private function isMagentoVersionLessThan($version)
146+
{
147+
return version_compare($this->productMetadataInterface->getVersion(), $version, '<') === true;
148+
}
149+
130150
/**
131151
* Add products with children
132152
*

0 commit comments

Comments
 (0)