Magento – Programmatically Load and Delete Products

Published 5 Comments on Magento – Programmatically Load and Delete Products

[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]

5 comments

  1. Fatal error: Call to a member function getModelInstance() on a non-object in dont work..

  2. Mage::register(‘isSecureArea’, 1);
    $productId=1577;
    $product = Mage::getModel(‘catalog/product’)->load($productId);
    $product->delete();

Comments are closed.