Skip to content

Commit 1365098

Browse files
authored
Merge pull request #5 from magento-troll/MDEE-46
MDEE-46: Prepare queries to get stock item status data from Magento
2 parents 73420ba + 4c951e1 commit 1365098

File tree

3 files changed

+50
-14
lines changed

3 files changed

+50
-14
lines changed

InventoryDataExporter/Model/Provider/StockStatus.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ public function get(array $values): array
5656
{
5757
$queryArguments = $this->data;
5858
foreach ($values as $value) {
59-
$queryArguments['itemIds'][] = $value['id'];
59+
$queryArguments['sourceItemIds'][] = $value['id'];
6060
}
6161
$output = [];
6262
$cursor = $this->queryProcessor->execute($this->queryName, $queryArguments);
6363
while ($row = $cursor->fetch()) {
6464
//TODO: extend query and remove this hardcode
65-
$row['sku'] = "TestSku";
66-
$row['qty'] = "10";
67-
$row['qtyForSale'] = "4.5";
68-
$row['infiniteStock'] = false;
69-
$row['lowStock'] = true;
70-
$row['updatedAt'] = "2021-07-22 17:38:36";
65+
// $row['sku'] = "TestSku";
66+
// $row['qty'] = "10";
67+
// $row['qtyForSale'] = "4.5";
68+
// $row['infiniteStock'] = false;
69+
// $row['lowStock'] = true;
70+
// $row['updatedAt'] = "2021-07-22 17:38:36";
7171
$output[] = $row;
7272
}
7373
return $output;

InventoryDataExporter/etc/mview.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Mview/etc/mview.xsd">
99
<view id="inventory_data_exporter_stock_status" class="Magento\InventoryDataExporter\Model\Indexer\StockStatusFeedIndexer" group="indexer">
1010
<subscriptions>
11-
<table name="cataloginventory_stock_item" entity_column="item_id" />
11+
<table name="inventory_source_item" entity_column="source_item_id" />
1212
</subscriptions>
1313
</view>
1414
</config>

InventoryDataExporter/etc/query.xml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,50 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_QueryXml:etc/query.xsd">
99
<query name="stockStatus">
10-
<source name="cataloginventory_stock_item">
11-
<attribute name="item_id" alias="id"/>
12-
<attribute name="stock_id" alias="stockId"/>
13-
<attribute name="qty" alias="qty"/>
14-
<attribute name="is_in_stock" alias="isSalable"/>
10+
<source name="inventory_source_item">
11+
<attribute name="source_item_id" alias="id"/>
12+
<attribute name="source_code" alias="sourceCode"/>
13+
<attribute name="sku" alias="sku"/>
14+
<attribute name="status" alias="isSalable"/>
1515
<filter glue="and">
16-
<condition attribute="item_id" operator="in" type="placeholder">itemIds</condition>
16+
<condition attribute="source_item_id" operator="in" type="placeholder">sourceItemIds</condition>
1717
</filter>
18+
<link-source name="inventory_source_stock_link" link-type="inner">
19+
<attribute name="stock_id" alias="stockId"/>
20+
<using glue="and">
21+
<condition attribute="source_code" operator="eq" type="identifier">source_code</condition>
22+
</using>
23+
</link-source>
24+
<link-source name="inventory_low_stock_notification_configuration" link-type="inner">
25+
<attribute name="notify_stock_qty" alias="notifyStockQty"/>
26+
<using glue="and">
27+
<condition attribute="source_code" operator="eq" type="identifier">source_code</condition>
28+
</using>
29+
<using glue="and">
30+
<condition attribute="sku" operator="eq" type="identifier">sku</condition>
31+
</using>
32+
</link-source>
33+
<link-source name="catalog_product_entity" link-type="inner">
34+
<attribute name="entity_id" alias="productId"/>
35+
<using glue="and">
36+
<condition attribute="sku" operator="eq" type="identifier">sku</condition>
37+
</using>
38+
</link-source>
39+
<link-source name="cataloginventory_stock_item" link-type="inner">
40+
<attribute name="min_sale_qty" alias="minSaleQty"/>
41+
<using glue="and">
42+
<condition attribute="product_id" operator="eq" type="identifier">catalog_product_entity.entity_id</condition>
43+
</using>
44+
</link-source>
45+
<link-source name="inventory_reservation" link-type="left">
46+
<attribute name="quantity" alias="reservedQty"/>
47+
<using glue="and">
48+
<condition attribute="sku" operator="eq" type="identifier">sku</condition>
49+
</using>
50+
<using glue="and">
51+
<condition attribute="stock_id" operator="eq" type="identifier">inventory_source_stock_link.stock_id</condition>
52+
</using>
53+
</link-source>
1854
</source>
1955
</query>
2056
</config>

0 commit comments

Comments
 (0)