0

Don't want to delete products, because i just assigned my products to my next store like adding another root category and assigned to categories, Same products assigned to two stores. How can i bulk Unassigned products from second store categories?

10
  • Are you know about Update attributes action in admin side under products grid? See here templatemonster.com/help/…
    – Abdul
    Commented Jan 2, 2018 at 13:18
  • Export the all-products CSV from Magento; Open with a Spreadsheet editor. Filter out the Store view you wish to delete. Save as .csv with the Filtered rows - Re-import with the Delete Command - if you're wanting to do this via the UI?
    – MackieeE
    Commented Jan 2, 2018 at 19:05
  • @Abdul my site consists 20k products, so not possible what you suggest if i try that my server getting down. So how can i do it by DB or CSV?
    – zus
    Commented Jan 3, 2018 at 9:06
  • @MackieeE can i get exact csv, my workout: website, sku delete entities-> it should be deleted both website
    – zus
    Commented Jan 3, 2018 at 9:24
  • @zus If you trying limited products (5k) then same issue?
    – Abdul
    Commented Jan 3, 2018 at 9:49

1 Answer 1

0

If you are a developer, you can try below code.

IMPORTANT: You should try this on a test environment with backup first as I haven't tested this code

To run this, create a php file in shell directory in magento root and save below code.

<?php

require_once 'abstract.php';

class Mage_Shell_ProductSave extends Mage_Shell_Abstract
{

    public function run()
    {
        //Change this before you run
        $websiteIdToRemoveProducts = 1;
        $resource = Mage::getSingleton('core/resource');
        $writeConnection = $resource->getConnection('core_write');
        $tableName = $resource->getTable('catalog/product_website');

        $query = "DELETE FROM `{{$tableName}` WHERE `website_id` = {$websiteIdToRemoveProducts}";
        $writeConnection->query($query);
    }

}

$shell = new Mage_Shell_ProductSave();
$shell->run();

Change the $websiteIdToRemoveProducts value before your run. Once you saved the code, run:

php yourFilename.php

From command line

After that run below command from the same path:

php indexer.php --reindexall

Then Flush your cache.

11
  • Fatal error: require_once(): Failed opening required 'abstract.php' (include_path='.;C:\php\pear') in C:\wamp\www\abc\mu.php on line
    – zus
    Commented Jan 3, 2018 at 11:45
  • justpaste.it/1f99g correct me.
    – zus
    Commented Jan 3, 2018 at 12:17
  • put your file in "shell" directory and then run
    – Nidheesh
    Commented Jan 3, 2018 at 12:37
  • @zus did that work for you?
    – Nidheesh
    Commented Jan 4, 2018 at 8:01
  • In my case, Don't want to delete products, because i just assigned my products to my next store like adding another root category and assigned to categories, Same products assigned to two stores. How can i bulk Unassiged products from second store categories?
    – zus
    Commented Jan 22, 2018 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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