Created
January 13, 2021 11:19
-
-
Save 6ui11em/8304efb3f4a01d9f3accd47c455c597a to your computer and use it in GitHub Desktop.
Magento: Query atributos entidades #magento #sql #eav #attributes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Category: | |
SET @entity_id = 1; | |
(SELECT e.attribute_code, 'varchar' AS type, v.store_id, v.value FROM catalog_category_entity_varchar v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'datetime' AS type, v.store_id, v.value FROM catalog_category_entity_datetime v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'decimal' AS type, v.store_id, v.value FROM catalog_category_entity_decimal v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'int' AS type, v.store_id, v.value FROM catalog_category_entity_int v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'text' AS type, v.store_id, v.value FROM catalog_category_entity_text v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
ORDER BY attribute_code; | |
-- Product: | |
SET @entity_id = 1; | |
(SELECT e.attribute_code, 'varchar' AS type, v.store_id, v.value FROM catalog_product_entity_varchar v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'datetime' AS type, v.store_id, v.value FROM catalog_product_entity_datetime v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'decimal' AS type, v.store_id, v.value FROM catalog_product_entity_decimal v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'int' AS type, v.store_id, v.value FROM catalog_product_entity_int v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'text' AS type, v.store_id, v.value FROM catalog_product_entity_text v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
ORDER BY attribute_code; | |
-- Customer: | |
SET @entity_id = 1; | |
(SELECT e.attribute_code, 'varchar' AS type, v.store_id, v.value FROM customer_entity_varchar v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'datetime' AS type, v.store_id, v.value FROM customer_entity_datetime v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'decimal' AS type, v.store_id, v.value FROM customer_entity_decimal v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'int' AS type, v.store_id, v.value FROM customer_entity_int v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'text' AS type, v.store_id, v.value FROM customer_entity_text v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
ORDER BY attribute_code; | |
-- Customer Address: | |
SET @entity_id = 1; | |
(SELECT e.attribute_code, 'varchar' AS type, v.store_id, v.value FROM customer_address_entity_varchar v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'datetime' AS type, v.store_id, v.value FROM customer_address_entity_datetime v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'decimal' AS type, v.store_id, v.value FROM customer_address_entity_decimal v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'int' AS type, v.store_id, v.value FROM customer_address_entity_int v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
UNION | |
(SELECT e.attribute_code, 'text' AS type, v.store_id, v.value FROM customer_address_entity_text v | |
JOIN eav_attribute e ON e.attribute_id = v.attribute_id WHERE v.entity_id = @entity_id) | |
ORDER BY attribute_code; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment