Skip to content

Commit e951add

Browse files
Pradeep KanakaPradeep Kanaka
authored andcommitted
Fix class not found error
1 parent af7e37a commit e951add

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

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

Lines changed: 25 additions & 12 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,21 +119,25 @@ 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") {
117-
return $changeLogWalkerFactory->create(
118-
\Magento\Framework\Mview\View\ChangeLogBatchWalker::class // @phpstan-ignore-line
122+
if ($this->isMagentoVersionLessThan("2.4.7")) {
123+
return $this->objectManager->create(
124+
\Magento\Framework\Mview\View\ChangeLogBatchWalkerFactory::class // @phpstan-ignore-line
119125
);
120126
}
121-
122-
$changelogWalkerFactory = $this->objectManager->create(
127+
return $this->objectManager->create(
123128
\Magento\Framework\Mview\View\ChangelogBatchWalkerFactory::class // @phpstan-ignore-line
124129
);
125-
return $changelogWalkerFactory->create(
126-
\Magento\Framework\Mview\View\ChangelogBatchWalker::class // @phpstan-ignore-line
127-
);
130+
}
131+
132+
/**
133+
* Returns true if the version is lower than the expected version
134+
*
135+
* @param $version
136+
* @return bool
137+
*/
138+
private function isMagentoVersionLessThan($version)
139+
{
140+
return version_compare($this->productMetadataInterface->getVersion(), $version, '<') === true;
128141
}
129142

130143
/**

0 commit comments

Comments
 (0)