Skip to main content
Share Your Experience: Take the 2024 Developer Survey
26 votes

Magento 2: Delete magento product attributes?

If you do not see the delete attribute button then that means the table column 'is_user_defined' in the eav_attribute table is set to 0. By changing this to 1 it will show the delete button. If you ...
danmentzer's user avatar
24 votes
Accepted

Truncate table using resource model in Magento 2

You can truncate table using DB Adapter and table name. /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */ $connection = $model->getResource()->getConnection(); $tableName = ...
Max's user avatar
  • 4,054
10 votes

can not able to delete the images of products

I had a the described issue two weeks ago. The image was not removed from the products Images tab, because the setting from the default scope was overwritten on store view level. So I would suggest ...
powlomat's user avatar
  • 171
10 votes
Accepted

How to delete a product in Magento-2 programmatically?

If you try to delete product from fronend then you need to assign area for that. Add following code to your class. public function __construct( ........ \Magento\Catalog\Model\...
Sohel Rana's user avatar
  • 35.9k
7 votes
Accepted

How do I delete a customer account programmatically in Magento2 CE?

Customer delete operation is valid from admin only. When you perform delete operation, magento check isSecureArea is true/false. So you can assign isSecureArea by following way: /** * @var \Magento\...
Sohel Rana's user avatar
  • 35.9k
7 votes
Accepted

how can I empty magento 2 orders, customer and products data reset to 1

Be safe: make a backup of your SQL first. SET FOREIGN_KEY_CHECKS = 0; Truncate order tables: TRUNCATE TABLE `gift_message`; TRUNCATE TABLE `quote`; TRUNCATE TABLE `quote_address`; TRUNCATE TABLE `...
Mohit Kumar Arora's user avatar
6 votes
Accepted

What are the footprints a magento module can leave in the magento system?

Here's the personal list I made up over the years: app/code/<codePool> folder app/etc/modules file app/locale translation and email files app/design layout and template files js libraries lib ...
Raphael at Digital Pianism's user avatar
6 votes
Accepted

Magento2 mini cart item delete alert

I you are still looking for an answer, the modal confirmation is created in vendor/magento/module-checkout/view/frontend/web/js/sidebar.js and it's a parameter named confirm: /** * @...
Korniow's user avatar
  • 96
6 votes
Accepted

While trying to delete address its redirecting to 404 page in Magento 2

I got the solution. Change 'HttpPostActionInterface' with 'HttpGetActionInterface'. vendor/magento/module-customer/Controller/Address/delete.php use Magento\Framework\App\Action\...
soofz's user avatar
  • 360
5 votes
Accepted

How to delete color attribute option by using label in Magento 2?

Try the below code: <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $eavAttribute = $objectManager->create('Magento\Eav\Model\Config'); $attribute = $eavAttribute-&...
Sukumar Gorai's user avatar
4 votes

Magento 2 Custom Module Delete Issue [SOLVED]

Check if you have following line in your Model\ResourceModel\Module\Collection.php file: protected $_idFieldName = 'module_id';
Suraj Wasnik's user avatar
4 votes
Accepted

Magento2 - How to remove item from wishlist?

You first need to inject several classes in your constructor protected $_wishlistProviderInterface; protected $_itemFactory; public __construct( ... \Magento\Wishlist\Controller\...
Raphael at Digital Pianism's user avatar
4 votes

How to delete a product in Magento-2 programmatically?

First, I suggest you try to avoid using the ObjectManager directly Second, I reckon you should use the \Magento\Catalog\Api\ProductRepositoryInterface service contrat to delete a product: protected $...
Raphael at Digital Pianism's user avatar
4 votes

How to delete products from frontend using object manager in magento 2?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $product = $objectManager->create('Magento\Catalog\Model\Product'); $product->load($productID)->delete();
Kishan Patadia's user avatar
4 votes
Accepted

How to clear cart and minicart programatically in Magento 2?

The mini cart items are from browser local storage. That means you need to reload the frontend cart section as well. An example here: https://magento.stackexchange.com/a/184745/33057
Khoa TruongDinh's user avatar
4 votes
Accepted

Magento : How to Alter Delete Confirm Message?

Add the following, just below parent::__construct();, in Nothing_Duty_Block_Adminhtml_Duty_Edit::__construct(): $objId = $this->getRequest()->getParam($this->_objectId); if (! empty($objId))...
Tim Cieplowski's user avatar
4 votes

How to delete object from collection in magento2

You can try below code for deleting it foreach ($collection as $key => $brand) { if ($brand->getIsDisabled()) { $collection->removeItemByKey($key); } }
Chức Cam Văn's user avatar
3 votes

How to delete a product in Magento-2 programmatically?

Indeed, you cannot delete product on the frontend area. You need to force the SecureArea registry. But if you check the register function, you see that you cannot override an existent key value. ...
Franck Garnier's user avatar
3 votes

Delete Product Magento 2

If you change this: $registry = $objectManager->create('\Magento\Framework\Registry'); To: $registry = $objectManager->get('\Magento\Framework\Registry'); It should work I believe.
muhsin's user avatar
  • 327
3 votes
Accepted

Delete all orders older than specific date by db query

you can try this, but backup first in case I'm wrong. I don't recommend using direct queries because you might end up with zombie data. You can create a script: First tell the script that you are ...
Marius's user avatar
  • 198k
3 votes

Magento 2: Delete magento product attributes?

You can remove unused product attributes in Magento 2 by using command line as well. php bin/magento catalog:product:attributes:cleanup Sees more details command line catalog:product:attributes:...
Namrata Vora's user avatar
3 votes

Magento2: How to remove created eav attribute for which is added through InstallData

You can just create Uninstall.php file inside setup folder . namespace Vendor\Sorting\Setup { class Uninstall implements \Magento\Framework\Setup\UninstallInterface { ...
Rakesh Jesadiya's user avatar
3 votes

Truncate table using resource model in Magento 2

Create a function in your ResourceModel app\code\Module\Namespace\Model\ResourceModel Inventory.php <?php namespace Module\Namespace\Model\ResourceModel; class Inventory extends \Magento\...
Rajeev Singh's user avatar
3 votes

update.log is 64 GB, can I delete it?

Of course, you can delete it. Its just a log. There will nothing happen if it is not longer available. Delete it and Magento will create another one once it found something to log.
Marcel H.'s user avatar
  • 147
3 votes
Accepted

Add 'Delete my account' link in Customer Navigation Menu

app/design/frontend/{package}/{theme}/layout/local.xml For the Customer account navigation : <customer_account> <reference name="customer_account_navigation"> <action ...
PЯINCƎ's user avatar
  • 11.7k
3 votes
Accepted

How to delete compare and shop by function in Magento 2

You can't! Not even through the command line. The Compare function of your Shop is part of the core. If you try to delete that module, your shop won't work anymore. If you just don't want to use the ...
David Lambauer's user avatar
3 votes

How to clear cart and minicart programatically in Magento 2?

May be this code will help your logic : $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cartObject = $objectManager->create('Magento\Checkout\Model\Cart')->truncate(); ...
Shashank Gupta's user avatar
3 votes
Accepted

Delete product from Magento 2

You can delete a single product or several products at once by going to Admin, Catalog, Products, then ticking the checkbox next to each product to delete. Then select 'Delete' from the 'Actions' drop-...
ProcessEight's user avatar
  • 1,000
3 votes
Accepted

Delete Product Custom Option value if it is null in magento 2

By using below function you can delete the custom options values. Here I compared the value title as NULL and delete the custom options values $obj = \Magento\Framework\App\ObjectManager::getInstance()...
Sathishkumar's user avatar
3 votes
Accepted

How to Delete Quote item Based on the condition in magento 2

Try below code: use Magento\Framework\Controller\ResultFactory; Class DeleteItem extends \Magento\Framework\App\Action\Action{{ protected $checkoutSession; protected $cart; ...
Khushbu's user avatar
  • 825

Only top scored, non community-wiki answers of a minimum length are eligible