Skip to content

Commit

Permalink
Merge pull request #5 from magento-troll/MDEE-46
Browse files Browse the repository at this point in the history
MDEE-46: Prepare queries to get stock item status data from Magento
  • Loading branch information
le0n4ik authored Oct 19, 2021
2 parents 73420ba + 4c951e1 commit 1365098
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
14 changes: 7 additions & 7 deletions InventoryDataExporter/Model/Provider/StockStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ public function get(array $values): array
{
$queryArguments = $this->data;
foreach ($values as $value) {
$queryArguments['itemIds'][] = $value['id'];
$queryArguments['sourceItemIds'][] = $value['id'];
}
$output = [];
$cursor = $this->queryProcessor->execute($this->queryName, $queryArguments);
while ($row = $cursor->fetch()) {
//TODO: extend query and remove this hardcode
$row['sku'] = "TestSku";
$row['qty'] = "10";
$row['qtyForSale'] = "4.5";
$row['infiniteStock'] = false;
$row['lowStock'] = true;
$row['updatedAt'] = "2021-07-22 17:38:36";
// $row['sku'] = "TestSku";
// $row['qty'] = "10";
// $row['qtyForSale'] = "4.5";
// $row['infiniteStock'] = false;
// $row['lowStock'] = true;
// $row['updatedAt'] = "2021-07-22 17:38:36";
$output[] = $row;
}
return $output;
Expand Down
2 changes: 1 addition & 1 deletion InventoryDataExporter/etc/mview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Mview/etc/mview.xsd">
<view id="inventory_data_exporter_stock_status" class="Magento\InventoryDataExporter\Model\Indexer\StockStatusFeedIndexer" group="indexer">
<subscriptions>
<table name="cataloginventory_stock_item" entity_column="item_id" />
<table name="inventory_source_item" entity_column="source_item_id" />
</subscriptions>
</view>
</config>
48 changes: 42 additions & 6 deletions InventoryDataExporter/etc/query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,50 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_QueryXml:etc/query.xsd">
<query name="stockStatus">
<source name="cataloginventory_stock_item">
<attribute name="item_id" alias="id"/>
<attribute name="stock_id" alias="stockId"/>
<attribute name="qty" alias="qty"/>
<attribute name="is_in_stock" alias="isSalable"/>
<source name="inventory_source_item">
<attribute name="source_item_id" alias="id"/>
<attribute name="source_code" alias="sourceCode"/>
<attribute name="sku" alias="sku"/>
<attribute name="status" alias="isSalable"/>
<filter glue="and">
<condition attribute="item_id" operator="in" type="placeholder">itemIds</condition>
<condition attribute="source_item_id" operator="in" type="placeholder">sourceItemIds</condition>
</filter>
<link-source name="inventory_source_stock_link" link-type="inner">
<attribute name="stock_id" alias="stockId"/>
<using glue="and">
<condition attribute="source_code" operator="eq" type="identifier">source_code</condition>
</using>
</link-source>
<link-source name="inventory_low_stock_notification_configuration" link-type="inner">
<attribute name="notify_stock_qty" alias="notifyStockQty"/>
<using glue="and">
<condition attribute="source_code" operator="eq" type="identifier">source_code</condition>
</using>
<using glue="and">
<condition attribute="sku" operator="eq" type="identifier">sku</condition>
</using>
</link-source>
<link-source name="catalog_product_entity" link-type="inner">
<attribute name="entity_id" alias="productId"/>
<using glue="and">
<condition attribute="sku" operator="eq" type="identifier">sku</condition>
</using>
</link-source>
<link-source name="cataloginventory_stock_item" link-type="inner">
<attribute name="min_sale_qty" alias="minSaleQty"/>
<using glue="and">
<condition attribute="product_id" operator="eq" type="identifier">catalog_product_entity.entity_id</condition>
</using>
</link-source>
<link-source name="inventory_reservation" link-type="left">
<attribute name="quantity" alias="reservedQty"/>
<using glue="and">
<condition attribute="sku" operator="eq" type="identifier">sku</condition>
</using>
<using glue="and">
<condition attribute="stock_id" operator="eq" type="identifier">inventory_source_stock_link.stock_id</condition>
</using>
</link-source>
</source>
</query>
</config>

0 comments on commit 1365098

Please sign in to comment.