Skip to main content
added 4 characters in body
Source Link

The selected answer doesn't consider MSI. in order to avoid generation a salable qty issue. You could also add this code,

`public`

public function fixReservationForUncancel(String $incrementId, String $sku, int $qty){

    /** @var \Magento\Framework\ObjectManagerInterface $objectManager */
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

    /** @var Magento\Framework\App\ResourceConnection $resourceConnection */
    $resourceConnection = $objectManager->create(\Magento\Framework\App\ResourceConnection::class);

    $connection = $resourceConnection->getConnection();
    $tableName = $resourceConnection->getTableName('inventory_reservation');

    $insertQuerry= [
        'stock_id' => 1,//Check your stock id in the same reservation table
        'sku' => $sku,
        'quantity' => $qty*-1,
        'metadata' => '{"event_type":"order_uncancel","object_type":"order","object_id":"","object_increment_id":"'. $incrementId .'"}'
    ];
    
    $qry= $connection->insert($tableName, $insertQuerry);

}`

`

The selected answer doesn't consider MSI. in order to avoid generation a salable qty issue. You could also add this code,

`public function fixReservationForUncancel(String $incrementId, String $sku, int $qty){

    /** @var \Magento\Framework\ObjectManagerInterface $objectManager */
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

    /** @var Magento\Framework\App\ResourceConnection $resourceConnection */
    $resourceConnection = $objectManager->create(\Magento\Framework\App\ResourceConnection::class);

    $connection = $resourceConnection->getConnection();
    $tableName = $resourceConnection->getTableName('inventory_reservation');

    $insertQuerry= [
        'stock_id' => 1,//Check your stock id in the same reservation table
        'sku' => $sku,
        'quantity' => $qty*-1,
        'metadata' => '{"event_type":"order_uncancel","object_type":"order","object_id":"","object_increment_id":"'. $incrementId .'"}'
    ];
    
    $qry= $connection->insert($tableName, $insertQuerry);

}`

The selected answer doesn't consider MSI. in order to avoid generation a salable qty issue. You could also add this code,

`

public function fixReservationForUncancel(String $incrementId, String $sku, int $qty){

    /** @var \Magento\Framework\ObjectManagerInterface $objectManager */
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

    /** @var Magento\Framework\App\ResourceConnection $resourceConnection */
    $resourceConnection = $objectManager->create(\Magento\Framework\App\ResourceConnection::class);

    $connection = $resourceConnection->getConnection();
    $tableName = $resourceConnection->getTableName('inventory_reservation');

    $insertQuerry= [
        'stock_id' => 1,//Check your stock id in the same reservation table
        'sku' => $sku,
        'quantity' => $qty*-1,
        'metadata' => '{"event_type":"order_uncancel","object_type":"order","object_id":"","object_increment_id":"'. $incrementId .'"}'
    ];
    
    $qry= $connection->insert($tableName, $insertQuerry);

}

`

Source Link

The selected answer doesn't consider MSI. in order to avoid generation a salable qty issue. You could also add this code,

`public function fixReservationForUncancel(String $incrementId, String $sku, int $qty){

    /** @var \Magento\Framework\ObjectManagerInterface $objectManager */
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

    /** @var Magento\Framework\App\ResourceConnection $resourceConnection */
    $resourceConnection = $objectManager->create(\Magento\Framework\App\ResourceConnection::class);

    $connection = $resourceConnection->getConnection();
    $tableName = $resourceConnection->getTableName('inventory_reservation');

    $insertQuerry= [
        'stock_id' => 1,//Check your stock id in the same reservation table
        'sku' => $sku,
        'quantity' => $qty*-1,
        'metadata' => '{"event_type":"order_uncancel","object_type":"order","object_id":"","object_increment_id":"'. $incrementId .'"}'
    ];
    
    $qry= $connection->insert($tableName, $insertQuerry);

}`