Skip to content

Instantly share code, notes, and snippets.

@bkozora
Created April 12, 2016 13:14
Show Gist options
  • Save bkozora/db6798ad9687f09f7850b2ee47a3b518 to your computer and use it in GitHub Desktop.
Save bkozora/db6798ad9687f09f7850b2ee47a3b518 to your computer and use it in GitHub Desktop.
Returns Descriptions for all active Magento products
SELECT
e.entity_id,
e.sku,
eav.value AS 'description',
IF(at_status.value_id > 0,
at_status.value,
at_status_default.value) AS `status`
FROM
catalog_product_entity e
JOIN
catalog_product_entity_text eav ON e.entity_id = eav.entity_id
JOIN
eav_attribute ea ON eav.attribute_id = ea.attribute_id
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` = '89')
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` = '89')
AND (`at_status`.`store_id` = 1)
WHERE
ea.attribute_code = 'description'
AND IF(at_status.value_id > 0,
at_status.value,
at_status_default.value) = 1
LIMIT 9999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment