Programmatically remove product from CATALOG (by ID)

Submitted by metaharper - 5 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.

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"; }
Learn PHP
comments powered by Disqus
Proudly hosted on Digital Ocean