Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/code/Ometria/AbandonedCarts/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Ometria_AbandonedCarts" setup_version="2.5.1"/>
<module name="Ometria_AbandonedCarts" setup_version="2.5.2"/>
</config>
2 changes: 1 addition & 1 deletion app/code/Ometria/Api/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Ometria_Api" setup_version="2.5.1"/>
<module name="Ometria_Api" setup_version="2.5.2"/>
</config>
33 changes: 21 additions & 12 deletions app/code/Ometria/Core/Plugin/OrderManagementPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,33 @@ private function sendPushNotifications(OrderInterface $order)
}

foreach ($order->getItems() as $orderItem) {
if ($orderItem->getHasChildren() == true) {
// Skip parent items (configurable product parents etc)
continue;
}

// Retrieve the salable qty of the product based on configured scope
$salableQty = $this->getSalableQty(
$orderItem->getProduct(),
$stockPushScope
);

// if salable qty is set and not already 0, check if push is required (null infers manage stock is disabled)
if ($salableQty !== null && $salableQty > 0) {
// Calculate new salabale quantity (after order placement)
$salableQtyAfterOrder = $salableQty - $orderItem->getQtyOrdered();
if ($salableQtyAfterOrder <= 0) {
$stockData = $this->inventoryService->getPushApiStockData(
(int)$orderItem->getProductId(),
false
);

$this->pushApiService->pushRequest($stockData);
}
if ($this->inventoryService->isReservationsAfter()) {
/*
* Adjust salable qty to compensate for a core API inconsistency across Magento versions
* which affects the salable quantity calculation based on the order in which reservations are deducted.
*/
$salableQty = $salableQty - $orderItem->getQtyOrdered();
}

// If salable qty is set, check if push is required for zero stock (null implies manage stock is disabled)
if ($salableQty !== null && $salableQty <= 0) {
$stockData = $this->inventoryService->getPushApiStockData(
(int)$orderItem->getProductId(),
false
);

$this->pushApiService->pushRequest($stockData);
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions app/code/Ometria/Core/Service/Product/Inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Magento\Framework\Module\Manager as ModuleManager;
use Magento\InventoryConfigurationApi\Api\GetStockItemConfigurationInterface;
use Magento\InventoryConfigurationApi\Exception\SkuIsNotAssignedToStockException;
use Magento\InventorySales\Plugin\Sales\OrderManagement\AppendReservationsAfterOrderPlacementPlugin;
use Magento\InventorySalesAdminUi\Model\ResourceModel\GetAssignedStockIdsBySku;
use Magento\InventorySalesApi\Api\Data\SalesChannelInterface;
use Magento\InventorySalesApi\Api\GetProductSalableQtyInterface;
Expand Down Expand Up @@ -132,6 +133,21 @@ public function addLegacyStockFilterToCollection(ProductCollection $collection)
}
}

/**
* This function checks which implementation exists in the AppendReservations plugin to determine
* whether the salable qty of a product will reflect the ordered amount inclusive of reservation or not.
*
* As of magento/[email protected] the afterPlace() function was replaced with an aroundPlace()
* function, resulting in the reservations being applied before the order placement (despite the plugin
* being named "AfterOrderPlacement").
*
* @return bool
*/
public function isReservationsAfter()
{
return method_exists(AppendReservationsAfterOrderPlacementPlugin::class, 'afterPlace');
}

/**
* @param ProductInterface $product
* @param $stockId
Expand Down
2 changes: 1 addition & 1 deletion app/code/Ometria/Core/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Ometria_Core" setup_version="2.5.1"/>
<module name="Ometria_Core" setup_version="2.5.2"/>
</config>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ometria/magento2",
"type": "magento2-module",
"version": "2.5.1",
"version": "2.5.2",
"description": "Dev composer package for Ometria Extension",
"authors": [
{
Expand Down