considering that I can not go to adminpanel--> catalog-->product page due to errors I have, how can I delete all products from one of my store views?


Try This code :-

    $mageFilename = 'app/Mage.php';
    require_once $mageFilename;
    ini_set('display_errors', 1);
    Mage::register('isSecureArea', 1);
        Mage :: app("default") -> setCurrentStore( Mage_Core_Model_App :: ADMIN_STORE_ID );
        $products = Mage :: getResourceModel('catalog/product_collection')->setStoreId(1)->getAllIds();
            foreach ($products as $key => $pId)
                    $product = Mage::getModel('catalog/product')->load($pId)->delete();
                catch (Exception $e) 
                    echo "Could not delete product with ID: ". $pId ."<br />";

  • Due to my limit access I couldn't run the code. I will accept as soon as I try it. – Zinat Oct 21 '15 at 11:57
  • You might want to be careful running that, make sure you backup before hand. But wont you need to remove it from the store view by getting the store views from the product and unsetting the one which you require - delete would completely delete the product from the whole install i think? – John Cuthbert Oct 21 '15 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.