[php]
<?php
// Register a secure admin environment
Mage::register(‘isSecureArea’, 1);
// Load the Magento product by entity_id
$product = Mage::getModel(‘catalog/product’)->load($productId);
// Load the Magento product by sku
$product = Mage::getModel(‘catalog/product’)->loadByAttribute(‘sku’, $productSku);
// Load the Magento product by name
$product = Mage::getModel(‘catalog/product’)->loadByAttribute(‘name’, $productName);
// Delete the product
$product->delete();
?>
[/php]
Fatal error: Call to a member function getModelInstance() on a non-object in dont work..
it’s not working
Can you share your full code? Where are you running this code?
Mage::register(‘isSecureArea’, 1);
$productId=1577;
$product = Mage::getModel(‘catalog/product’)->load($productId);
$product->delete();
If you’re using an external script, remember to:
require_once( ‘./app/Mage.php’ );
Mage::app();