Skip to content

Instantly share code, notes, and snippets.

@jonatanrdsantos
Created September 26, 2019 15:19
Show Gist options
  • Save jonatanrdsantos/2972ea9eb2c28b55f15a86d668cc6b5f to your computer and use it in GitHub Desktop.
Save jonatanrdsantos/2972ea9eb2c28b55f15a86d668cc6b5f to your computer and use it in GitHub Desktop.
Get all magento 2 enabled products, change 98 for the status attributes
SELECT `e`.*, IF(at_status.value_id > 0, at_status.value, at_status_default.value) AS `status`
FROM `catalog_product_entity` AS `e`
INNER JOIN `catalog_product_entity_int` AS `at_status_default`
ON (`at_status_default`.`entity_id` = `e`.`entity_id`)
AND (`at_status_default`.`attribute_id` = '98')
AND `at_status_default`.`store_id` = 0
LEFT JOIN `catalog_product_entity_int` AS `at_status`
ON (`at_status`.`entity_id` = `e`.`entity_id`)
AND (`at_status`.`attribute_id` = '98')
AND (`at_status`.`store_id` = 1)
WHERE (IF(at_status.value_id > 0, at_status.value, at_status_default.value) = '1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment