I dont know why i am not getting what i want after executing my query AND i was not able to find an attribute.
Let me explain everything:
First off, i wanted to get all the products that had these attributes:
SKU, code_brand, code_business_unit, code_line, code_group, code_business and min_sale_qty
This is my query:
SELECT main.entity_id,main.sku,code_brand.value AS code_brand, code_business_unit.value AS code_business_unit, code_line.value AS code_line, code_group.value AS code_group, code_business.value AS code_business
FROM catalog_product_entity AS main
LEFT JOIN catalog_product_entity_int AS code_brand
ON main.entity_id = code_brand.entity_id
LEFT JOIN catalog_product_entity_varchar AS code_business_unit
ON main.entity_id = code_business_unit.entity_id
LEFT JOIN catalog_product_entity_varchar AS code_line
ON main.entity_id = code_line.entity_id
LEFT JOIN catalog_product_entity_int AS code_group
ON main.entity_id = code_group.entity_id
LEFT JOIN catalog_product_entity_int AS code_business
ON main.entity_id = code_business.entity_id
WHERE code_brand.attribute_id = (
SELECT attribute_id
FROM eav_attribute
WHERE attribute_code LIKE 'code_brand'
AND `entity_type_id` = (
SELECT entity_type_id
FROM eav_entity_type
WHERE entity_type_code = 'catalog_product'
)
)
AND code_business_unit.attribute_id = (
SELECT attribute_id
FROM eav_attribute
WHERE attribute_code LIKE 'code_business_unit'
AND `entity_type_id` = (
SELECT entity_type_id
FROM eav_entity_type
WHERE entity_type_code = 'catalog_product'
)
)
AND code_line.attribute_id = (
SELECT attribute_id
FROM eav_attribute
WHERE attribute_code LIKE 'code_line'
AND `entity_type_id` = (
SELECT entity_type_id
FROM eav_entity_type
WHERE entity_type_code = 'catalog_product'
)
)
AND code_group.attribute_id = (
SELECT attribute_id
FROM eav_attribute
WHERE attribute_code LIKE 'code_group'
AND `entity_type_id` = (
SELECT entity_type_id
FROM eav_entity_type
WHERE entity_type_code = 'catalog_product'
)
)
AND code_business.attribute_id = (
SELECT attribute_id
FROM eav_attribute
WHERE attribute_code LIKE 'code_business'
AND `entity_type_id` = (
SELECT entity_type_id
FROM eav_entity_type
WHERE entity_type_code = 'catalog_product'
)
)
It works but i am not getting the correct results, take a look at this picture:
Why, what is going on?
Also, i was not able to find this attribute: min_sale_qty
After executing this query i got no results:
select
backend_type from eav_attribute
where attribute_code like "min_sale_qty"
I found this attribute in this table:
This is the database diagram: