For those of you who wish to use a script or otherwise to delete a product or perhaps perform another “admin only” function outside of the Magento installation you need to do the following, which will obviously boot up Magento for you to start using.
require_once('app/Mage.php'); //Path to Magentoumask(0);Mage:app();To delete a product you would normally then perform the following:
$product = Mage::getModel('catalog/product')->load($id);$product->delete();However you may notice that on some versions of Magento you will be slapped in the face with the following message:
Fatal error: Uncaught exception ‘Mage_Core_Exception’ with message ‘Cannot complete this operation from non-admin area.’
This means that some functions within the Magento arsenal can only be performed via the admin side of the site. To do this outside of Magento you will need to change:
// Mage:app();// ToMage::app("default")->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);This will boot up the admin side of you Magento store – and will allow you to delete your products! Thanks for visiting the Magento Blog here at E-commerce Web Design, home of the Magento Fox!
Robert Kent Author Page
There are lot's of great thing in Magento but this is a Best thing ever i seen thanks for sharing..
Trả lờiXóaMagento Modules