10
10
use Magento \Catalog \Api \Data \ProductInterface ;
11
11
use Magento \Framework \App \ResourceConnection ;
12
12
use Magento \Framework \EntityManager \MetadataPool ;
13
- use Magento \Inventory \Model \ResourceModel \SourceItem ;
14
13
15
14
/**
16
15
* Provides product ids related to specified source items ids.
@@ -27,16 +26,34 @@ class GetProductIdsBySourceItemIds
27
26
*/
28
27
private $ metadataPool ;
29
28
29
+ /**
30
+ * @var string
31
+ */
32
+ private $ tableNameSourceItem ;
33
+
34
+ /**
35
+ * @var string
36
+ */
37
+ private $ sourceItemIdFieldName ;
38
+
30
39
/**
31
40
* GetProductIdsByStockIds constructor.
32
41
*
33
42
* @param ResourceConnection $resource
34
43
* @param MetadataPool $metadataPool
44
+ * @param string $tableNameSourceItem
45
+ * @param string $sourceItemIdFieldName
35
46
*/
36
- public function __construct (ResourceConnection $ resource , MetadataPool $ metadataPool )
37
- {
47
+ public function __construct (
48
+ ResourceConnection $ resource ,
49
+ MetadataPool $ metadataPool ,
50
+ $ tableNameSourceItem ,
51
+ $ sourceItemIdFieldName
52
+ ) {
38
53
$ this ->resource = $ resource ;
39
54
$ this ->metadataPool = $ metadataPool ;
55
+ $ this ->tableNameSourceItem = $ tableNameSourceItem ;
56
+ $ this ->sourceItemIdFieldName = $ sourceItemIdFieldName ;
40
57
}
41
58
42
59
/**
@@ -50,13 +67,13 @@ public function execute(array $sourceItemIds): array
50
67
{
51
68
$ productLinkField = $ this ->metadataPool ->getMetadata (ProductInterface::class)->getLinkField ();
52
69
$ connection = $ this ->resource ->getConnection ();
53
- $ sourceItemTable = $ this ->resource ->getTableName (SourceItem:: TABLE_NAME_SOURCE_ITEM );
70
+ $ sourceItemTable = $ this ->resource ->getTableName ($ this -> tableNameSourceItem );
54
71
$ select = $ connection ->select ()
55
72
->from (
56
73
['source_items_table ' => $ sourceItemTable ],
57
74
[]
58
75
)->where (
59
- SourceItem:: ID_FIELD_NAME . ' IN (?) ' ,
76
+ $ this -> sourceItemIdFieldName . ' IN (?) ' ,
60
77
$ sourceItemIds
61
78
)->join (
62
79
['product_table ' => $ this ->resource ->getTableName ('catalog_product_entity ' )],
0 commit comments