Need a function for adding a product to the order on sales_order_place_after event for Magento 2

Job ID: 35559111

Budget: £20 – £250 GBP

I need a developer to write a function for my existing extension to add the product(s) to the order.
The extension uses an observer for the event sales_order_place_after (to make sure changes are made only after successful payment), and I partly managed to do it, but the added product does not meet all my requirements:

- added products will have changed only price (free = 0) and name (added SKU of the parent product is added free for. In brackets). For example: SD Card 32GB (free for CAM-SONY-XY). The rest attributes are the same as the product from catalog with this SKU.
- if a product with the same SKU already exists on the order, an added product must be listed separately (every time will have a different name)
- added product must be reduced from the stock (if 3 added -3 deducted from Magento catalog)
- added product must be the same on the order as the one added manually while creating the order (it must look the same on the order/invoice and in the database).

To clarify, here is a part of my extension for which I need a function addFreeItem to be developed.

public function execute (\Magento\Framework\Event\Observer $observer)
{
$order = $observer->getEvent()->getOrder();

$extraPorductSku1 = 'ABC123';
$prantProductSku1 = 'CAM-SONY-XY';
$extraPorductSku2 = 'XYZ123';
$prantProductSku2 = 'PHONE-SAMSUNG-XX';

$this->addFreeItem($extraPorductSku1, 2, $prantProductSku1);
$this->addFreeItem($extraPorductSku2, 3, $prantProductSku2);

}

protected function addFreeItem(FreeSku $freeSku, Qty $qty, ParentSku $parentSku)
{
$newPrice = 0;

.............
CODE NEEDED
..............

}
Related categories: Magento Magento 2