11<?php
22namespace Hackathon \EAVCleaner \Console \Command ;
33
4+ use Magento \Framework \App \ProductMetadataInterface ;
45use Symfony \Component \Console \Command \Command ;
56use Symfony \Component \Console \Input \InputInterface ;
67use 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 entity_id = ? AND value = ? ' ,
66- array ($ row ['attribute_id ' ], 0 , $ row [' entity_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