1

Unable to get the registry for current product by selecting the product in magento 2.

Im trying to update the product id of the product which gets deleted from below code during the delete event catalog_product_delete_after:

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
$productdel = $objectManager->get('Magento\Framework\Registry')->registry('current_product');  
$productid=$productdel->getEntityId(); 
 ....

I get getEntityId() on null.

I m just selecting the checkbox of the product to be deleted in backend and i guess its not able to get the productid in the current registry.

OTHER CASE:

The above works if i try to update any product attribute.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.