Magento Coding Solutions

Remove assign category from product

/*-----------Remove product From assign category Start------------- */
$productId=5;
$product=Mage::getModel("catalog/product")->load($productId);
$productIdss=$product->getId();
$all_cats = $product->getCategoryIds($productIdss);
  foreach($all_cats as $_catId)
{
$product=Mage::getSingleton('catalog/category_api')->removeProduct($_catId,$productIdss);
}
/*-----------Remove product From assign category End------------- */

Magento programmatically remove product images

/* Remove Product media Image Start*/
$ptoductId=120;
$productImgRemov= Mage::getModel('catalog/product')->load($ptoductId);
$entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
$mediaGalleryAttribute = Mage::getModel('catalog/resource_eav_attribute')->loadByCode($entityTypeId, 'media_gallery');
$gallery = $productImgRemov->getMediaGalleryImages();
foreach ($gallery as $image)
$mediaGalleryAttribute->getBackend()->removeImage($productImgRemov, $image->getFile());
$productImgRemov->save();
/* Remove Product media Image End*/