0

Need to get all the unused attribute value and delete it via API. How to get the Unused attribute list using SQL Query.

0

Try the below Query in the Database

SELECT
  eao.attribute_id,
  ea.attribute_code,
  eaov.value_id,
  eaov.value
FROM eav_attribute_option AS eao
  INNER JOIN eav_attribute AS ea ON eao.attribute_id = ea.attribute_id
  INNER JOIN eav_attribute_option_value AS eaov ON eaov.option_id = eao.option_id
WHERE eao.option_id NOT IN (
  SELECT value
  FROM catalog_product_entity_int
  WHERE attribute_id = eao.attribute_id
) AND  ea.attribute_code = 'your_attribute_code';

It will lists options of your_attribute_code is not used by any product

Review the list option before deleting them

API

You can check the DELETE API in Swagger catalogProductAttributeOptionManagementV1

API URL: YourDoamin/rest/all/V1/products/attributes/**attribute_code**/options/**option_id**

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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