I have a module that needs to do the following steps because of translation requirements:

  • read new product data from a file
  • check if the product already exists
  • if already exists, remember some values from a specific store view, then delete
  • create the product from the source data
  • if remembered data, re-add data to specific store view of the newly created product

Because I need to check different store views for the product(s), I regularily load them from either admin store or any of the frontend visible store views.

However, I am unable to delete a product, even when loaded from the admin store view. The problem displays as follows:

#0 /var/www/outstore.tld/app/code/core/Mage/Core/Model/Abstract.php(517): Mage::throwException('Cannot complete...')
#1 /var/www/outstore.tld/app/code/core/Mage/Catalog/Model/Product.php(568): Mage_Core_Model_Abstract->_protectFromNonAdmin()
#2 /var/www/outstore.tld/app/code/core/Mage/Core/Model/Abstract.php(479): Mage_Catalog_Model_Product->_beforeDelete()
#3 /var/www/outstore.tld/app/code/core/Mage/Catalog/Model/Product.php(1529): Mage_Core_Model_Abstract->delete()
#4 /var/www/outstore.tld/.modman/ourmodule/shell/ourimporter.php(291): Mage_Catalog_Model_Product->delete()

The message given is:

Cannot complete this operation from non-admin area.

However, I was sure that I loaded the product from the admin store view:


A var_dump($existingProduct) showed me that I was right, the product was loaded from the admin store view.

Following the stack trace down, I find this code:

    if (Mage::registry('isSecureArea')) {
    if (!Mage::app()->getStore()->isAdmin()) {
        Mage::throwException(Mage::helper('core')->__('Cannot complete this operation from non-admin area.'));

I can see the workaround, just setting isSecureArea before attempting to delete, but I would like to understand both why the error message occurs, if it could be considered a bug, and what side effects (or rather, what main effect) setting isSecureArea has.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.