1

I am having the list of product sku. By using that Sku I need to disabled that products using a MySQL query. I don't know table structure and how to do it using sql query. Please advice me. Thanks in advance.

3 Answers 3

3

To disable product by using SKU. First of all find the attribute_id value for status.

Go to Admin > Catalog > Attributes > Manage Attributes

Then you will find list of attributes in Attribute Code Box type status and click on Search you will find status attribute click on it you will be redirected to edit page there in the url you will find

catalog_product_attribute/edit/attribute_id/**XXX**/key/

Copy the Attribute id and paste it in the SQL query run it in phpMyAdmin.

UPDATE catalog_product_entity_int a, catalog_product_entity b
SET a.value = "2"
WHERE b.entity_id = a.entity_id
AND b.sku LIKE '%SKU%'
AND a.attribute_id = **XXX**

After running the query Login to your admin and go to

  • System > Cache Management - > Clear Cache
  • System > Index management > Rebuild Catalog Index
1
  • 1
    Back up your database first!
    – jscar
    Sep 7, 2017 at 10:03
2

Magento 2 [EE] SQL Query as follows below.

To disable products by using SKU. Find the attribute_id value for status.

Step 1:

SELECT * FROM eav_attribute where entity_type_id = 4 AND attribute_code = 'status';

Step 2

UPDATE catalog_product_entity_int a, catalog_product_entity b
    SET a.value = "2"
    WHERE b.row_id = a.row_id
    AND b.sku LIKE '%SKU%'
    AND a.attribute_id = **attribute_code**

If you like the answer please give thumbs up.

Kindness is the best form of humanity.

0

Posting the answer here for posterity if somebody stumbles across this as i did: (magento 2.3.5 solution)

UPDATE 
    catalog_product_entity_int AI 
    INNER JOIN eav_attribute A ON AI.attribute_id = A.attribute_id
    INNER JOIN catalog_product_entity P ON AI.entity_id = P.entity_id
SET AI.value = "2"
WHERE 
    P.sku IN ( ... ) AND 
    A.attribute_code = 'status' AND 
    A.entity_type_id = 4

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.