Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all Custom option of all Products in Magento

Tags:

php

magento

I need to remove all custom option from all magento products. I have about 4k products. and all has custom option. now we don't need custom option. so we need to need to remove all. Is the any simple solution as if I can remove all custom option easily

thanks

like image 430
Shamim Ahmed Avatar asked Dec 12 '22 02:12

Shamim Ahmed


2 Answers

Preferably don't directly execute a database query, but use magento models:

<?php

require_once 'app/Mage.php';

Mage::init();

Mage::getModel('catalog/product_option')->getCollection()->walk('delete');

This -will- use multiple queries to delete your product options, but it should not be a big issue for 4000 products.

like image 190
Daniel Sloof Avatar answered Mar 05 '23 11:03

Daniel Sloof


If you need to remove all custom options from all products at once, then you can execute the following SQL query in your database:

delete from catalog_product_option

But be sure to backup your database first. Did you mean something like that.

like image 43
Sudhir Bastakoti Avatar answered Mar 05 '23 11:03

Sudhir Bastakoti