Skip to content

Commit 18a80e5

Browse files
committed
DD#0000: feat: Updated code to differentiate between enterprise and
community
1 parent f0f1c19 commit 18a80e5

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Console/Command/RestoreUseDefaultValueCommand.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Hackathon\EAVCleaner\Console\Command;
33

4+
use Magento\Framework\App\ProductMetadataInterface;
45
use Symfony\Component\Console\Command\Command;
56
use Symfony\Component\Console\Input\InputInterface;
67
use Symfony\Component\Console\Output\OutputInterface;
@@ -10,6 +11,20 @@ class RestoreUseDefaultValueCommand extends Command
1011
{
1112
public $questionHelper;
1213

14+
/**
15+
* @var ProductMetaDataInterface
16+
*/
17+
protected $productMetaData;
18+
19+
public function __construct(
20+
ProductMetaDataInterface $productMetaData,
21+
string $name = null
22+
)
23+
{
24+
parent::__construct($name);
25+
$this->productMetaData = $productMetaData;
26+
}
27+
1328
/**
1429
* Init command
1530
*/
@@ -52,6 +67,8 @@ public function execute(InputInterface $input, OutputInterface $output)
5267
$counts = array();
5368
$i = 0;
5469
$tables = array('varchar', 'int', 'decimal', 'text', 'datetime');
70+
$column = $this->productMetaData->getEdition() === 'Enterprise' ? 'row_id' : 'entity_id';
71+
5572

5673
foreach ($tables as $table) {
5774
// Select all non-global values
@@ -62,8 +79,8 @@ public function execute(InputInterface $input, OutputInterface $output)
6279
// Select the global value if it's the same as the non-global value
6380
$results = $db->fetchAll(
6481
'SELECT * FROM ' . $fullTableName
65-
. ' WHERE attribute_id = ? AND store_id = ? AND row_id = ? AND value = ?',
66-
array($row['attribute_id'], 0, $row['row_id'], $row['value'])
82+
. ' WHERE attribute_id = ? AND store_id = ? AND ' . $column . ' = ? AND value = ?',
83+
array($row['attribute_id'], 0, $row[$column], $row['value'])
6784
);
6885

6986
if (count($results) > 0) {

0 commit comments

Comments
 (0)