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

Created by Esther Nguyen, Modified on Wed, 22 Apr at 12:17 AM by Support Agent

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!


Count on us! Here are some information about BSS Commerce if you might be interested:


BSS Commerce is a full-service ecommerce agency with 14+ years of experience, supporting 75,000+ customers worldwide. As an Adobe Commerce Solution Bronze Partner and Select Magento Extensions Builder, we deliver trusted end-to-end solutions.

Our core strength is Magento, with 150+ extensions designed to enhance store performance and drive growth. With deep expertise from years of working on Magento websites, we deliver scalable, high-impact solutions backed by strong client trust.


Discover our extensions: https://bsscommerce.com/magento-2-extensions.html 


Our Magento B2B Extension by BSS Commerce is a flagship, widely used global solution, providing an all-in-one system for pricing, account management, and efficient B2B workflows. 


>>> If you want to improve your visibility, install Magento SEO Extension by BSS Commerce


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 know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article