-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from lizardmedia/enterprise-compatibility-patch
Enterprise compatibility fix
- Loading branch information
Showing
10 changed files
with
184 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* File: Version.php | ||
* | ||
* @author Bartosz Kubicki [email protected]> | ||
* @copyright Copyright (C) 2018 Lizard Media (http://lizardmedia.pl) | ||
*/ | ||
|
||
namespace LizardMedia\ProductAttachment\Helper; | ||
|
||
use Exception; | ||
use Magento\Catalog\Api\Data\ProductInterface; | ||
use Magento\Framework\App\ProductMetadata; | ||
use Magento\Framework\App\ProductMetadataInterface; | ||
use Magento\Framework\EntityManager\MetadataPool; | ||
|
||
/** | ||
* Various Helper | ||
* @package LizardMedia\ProductAttachment\Helper | ||
*/ | ||
class Version | ||
{ | ||
/** | ||
* @var ProductMetadataInterface | ||
*/ | ||
private $productMetadata; | ||
|
||
/** | ||
* @var MetadataPool | ||
*/ | ||
private $metadataPool; | ||
|
||
/** | ||
* @param ProductMetadataInterface $productMetadata | ||
* @param MetadataPool $metadataPool | ||
*/ | ||
public function __construct( | ||
ProductMetadataInterface $productMetadata, | ||
MetadataPool $metadataPool | ||
) { | ||
$this->productMetadata = $productMetadata; | ||
$this->metadataPool = $metadataPool; | ||
} | ||
|
||
/** | ||
* @return string | ||
* @throws Exception | ||
*/ | ||
public function getLinkFieldValue(): string | ||
{ | ||
return ( | ||
$this->productMetadata->getEdition() !== ProductMetadata::EDITION_NAME | ||
&& version_compare($this->productMetadata->getVersion(), '2.1.0', '>=') | ||
) | ||
? 'entity_id' | ||
: $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); | ||
} | ||
} |
Oops, something went wrong.