Useful direct SQL queries for Magento 2 developers

Select product default Attribute set id


Select product Attribute Group Id by using attribute_group_code and Attribute Set ID


Update attribute_group_id for product attribute


Update sort_order for product attribute


Delete a custom attribute using entity_type_id and attribute_code. Delete a custom attribute using entity_type_id and attribute_code.

 For this example, I am going to delete a product attribute, which has  attribute_code as ‘iyn_product_option’. To delete a custom attribute, we need to delete the data from the following tables.
Tables : eav_attribute_option_value,eav_attribute_option_swatch,eav_attribute_label,eav_attribute_option and eav_attribute.


Delete all products

To remove all URL rewrites related to the products, you can use that script SQL below.

To remove the URL rewrites that were automatically generated, you can use this one.

Select all the disabled products in Magento2



Be the first to comment

Leave a Reply

Your email address will not be published.