Programmatically remove product from CATALOG (by ID)

Submitted by deeperdata - 3 years ago

Discovered this gem while trying to find a way to "delete" a product from cart. I'm sure it could be useful to someone. NOTE: Literally, this deletes the product from Magento. Use it wisely.

<?php
Mage::register("isSecureArea", 1); $product_id = 222; //use your own product id
try{Mage::getModel("catalog/product")->load( $product_id  )->delete(); }catch(Exception $e){
    echo "Delete failed"; }
?>
affiliate_link
Learn PHP
comments powered by Disqus
Proudly hosted on Digital Ocean