Skip to content

Commit

Permalink
Compatible with Magento 2.4.7
Browse files Browse the repository at this point in the history
Backward compatibility has been lost in the Magento\Catalog\Model\ProductRepository class

Check the issue page in the Magento repo for reference: magento/magento2#38669
  • Loading branch information
TuVanDev committed May 9, 2024
1 parent 7eb828b commit f2b576e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 29 deletions.
85 changes: 58 additions & 27 deletions Model/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\App\Area;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\EntityManager\Operation\Read\ReadExtensions;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Filesystem;
Expand All @@ -50,6 +51,7 @@ class ProductRepository extends \Magento\Catalog\Model\ProductRepository
{
protected $imageHelperFactory;
protected $appEmulation;
private $productMetadataInterface;
private $stockRegistry;
private $cacheLimit = 0;
private $productHelperFactory;
Expand All @@ -61,6 +63,7 @@ class ProductRepository extends \Magento\Catalog\Model\ProductRepository
private $categoryListInterface;

public function __construct(
ProductMetadataInterface $productMetadataInterface,
ImageFactory $imageHelperFactory,
Emulation $appEmulation,
StockRegistryInterface $stockRegistry,
Expand Down Expand Up @@ -106,32 +109,60 @@ public function __construct(
$this->magentoStoreConfig = $magentoStoreConfig;
//Add here any custom attributes we want to exclude from indexation
$this->excludedCustomAttributes = ['special_price', 'special_from_date', 'special_to_date'];
parent::__construct(
$productFactory,
$initializationHelper,
$searchResultsFactory,
$collectionFactory,
$searchCriteriaBuilder,
$attributeRepository,
$resourceModel,
$linkInitializer,
$linkTypeProvider,
$storeManager,
$filterBuilder,
$metadataServiceInterface,
$extensibleDataObjectConverter,
$optionConverter,
$fileSystem,
$contentValidator,
$contentFactory,
$mimeTypeExtensionMap,
$imageProcessor,
$extensionAttributesJoinProcessor,
$collectionProcessor,
$serializer,
$cacheLimit,
$readExtensions
);
if (version_compare($productMetadataInterface->getVersion(), '2.4.7', '>=')) {
parent::__construct(
$productFactory,
$searchResultsFactory,
$collectionFactory,
$searchCriteriaBuilder,
$attributeRepository,
$resourceModel,
$linkInitializer,
$linkTypeProvider,
$storeManager,
$filterBuilder,
$metadataServiceInterface,
$extensibleDataObjectConverter,
$optionConverter,
$fileSystem,
$contentValidator,
$contentFactory,
$mimeTypeExtensionMap,
$imageProcessor,
$extensionAttributesJoinProcessor,
$collectionProcessor,
$serializer,
$cacheLimit,
$readExtensions
);
} else {
parent::__construct(
$productFactory,
$initializationHelper,
$searchResultsFactory,
$collectionFactory,
$searchCriteriaBuilder,
$attributeRepository,
$resourceModel,
$linkInitializer,
$linkTypeProvider,
$storeManager,
$filterBuilder,
$metadataServiceInterface,
$extensibleDataObjectConverter,
$optionConverter,
$fileSystem,
$contentValidator,
$contentFactory,
$mimeTypeExtensionMap,
$imageProcessor,
$extensionAttributesJoinProcessor,
$collectionProcessor,
$serializer,
$cacheLimit,
$readExtensions
);
}
}

/**
Expand Down Expand Up @@ -376,7 +407,7 @@ private function getCategoriesInformation($categories)
$categoryIds[$category->getCategoryId()] = true;
}
}

// Get table name with prefix if it exists
$catalogCategoryEntityTable = $this->resourceModel->getTable('catalog_category_entity');

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doofinder/doofinder-magento2",
"version": "0.13.13",
"version": "0.13.14",
"description": "Doofinder module for Magento 2",
"type": "magento2-module",
"require": {
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Doofinder_Feed" setup_version="0.13.13">
<module name="Doofinder_Feed" setup_version="0.13.14">
<sequence>
<module name="Magento_Integration" />
</sequence>
Expand Down

0 comments on commit f2b576e

Please sign in to comment.