M2.4.3, v1.1.6: Error when creating a product with same SKU as a deleted product

Created by Esther Nguyen, Modified on Mon, 01 Nov 2021 at 02:18 PM by Esther Nguyen

ISSUE:

We've got a problem with trying to recreate a product with the same SKU as a previously deleted product. Basically, I deleted a couple of products that were in order, and that means that the order now cannot be shipped or credit memo on the system. In the past (on 2.3.5) I have been able to simply create a new product with the same SKU as the old one, and then we're usually able to ship the order. However, we've just tried to do this (create a new product with the same SKU as the old one) and it gives us this error:

TypeError: Argument 1 passed to Magento\InventoryConfiguration\Model\IsSourceItemManagementAllowedForProductType\Interceptor::execute() must be of the type string, null given, called in /home/474972.cloudwaysapps.com/aatutsngpq/public_html/vendor/magento/module-inventory-sales/Model/GetProductSalableQty.php on line 108 and defined in /home/474972.cloudwaysapps.com/aatutsngpq/public_html/generated/code/Magento/InventoryConfiguration/Model/IsSourceItemManagementAllowedForProductType/Interceptor.php:20


SOLUTION:

When catching the "before save product" event, the get Salableqty function has not covered the case where the product has no source yet. As a result, when the product is deleted, there is no productType existing, and the function that checks allow product type will report an error. 


To resolve the issue, please edit the file: app/code/Bss/InventoryReport/Observer/SaveObserver.php as below:

If you need any further assistance, please feel free to contact us. We'd be happy to support you!

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us how can we improve this article!

Select atleast one of the reasons

Feedback sent

We apprciate your effort and will try to fix the article