deal with 'non-admin area' warn

We usually use the follow code to delete product in Magento

$product = Mage::getSingleton('catalog/product')->load($productId);
$product->delete();

 Of course, you are given a warn from magento. To solve this problem, you should add the follow code before and after delete

  Mage::register('isSecureArea', true);

  Mage::unregister('isSecureArea', true);

posted on 2014-04-12 19:53  冯亮  阅读(167)  评论(0编辑  收藏  举报

导航