Showing posts with label Current Area. Show all posts
Showing posts with label Current Area. Show all posts

Monday, 25 June 2018

Delete operation is forbidden for current area in Magento 2

You can use following code for Delete operation is forbidden for current area in products or any un secured area // Here is for product delete

$registry = $objectManager->get('\Magento\Framework\Registry');
$registry->register('isSecureArea', true);
$removeproduct = $objectManager->create('\Magento\Catalog\Model\Product');
$removeproduct->load(21); / Product id
$removeproduct->delete();