Skip to main content
10 events
when toggle format what by license comment
Mar 27, 2019 at 16:59 comment added programming_amazing @karpa No no, your query is good and helped me a lot but i am trying to do it in a different way :)
Mar 27, 2019 at 15:55 comment added karpa @programming_amazing do you have a particular reason that you don't like the solution i proposed? It works pretty good and does exactly what you need.
Mar 27, 2019 at 14:50 comment added HelgeB status is a simple eav attribute of type int, there is no option or option value table to be joined there. Therefore your last two joins of eav_attribute_option and eav_attribute_option_value can not work. Remove them and you will have the correct statement whitout subquery. You will still have to check that the value from the int table is 1.
Mar 27, 2019 at 13:32 comment added programming_amazing @HelgeB I am using this query: LEFT JOIN catalog_product_entity_int code_status ON main.entity_id = code_status.entity_id and code_status.attribute_id = attribute_code_status.attribute_id LEFT JOIN eav_attribute_option option_code_status on option_code_status.attribute_id = code_status.attribute_id and option_code_status.option_id = code_status.value LEFT JOIN eav_attribute_option_value option_value_code_status on option_code_status.option_id = option_value_code_status.option_id
Mar 27, 2019 at 13:29 comment added programming_amazing @HelgeB If i use this: option_value_code_status AS code_status it returns NULL but if i use this one: code_status.value AS code_status it returns 1. Why? Whats the difference?
Mar 27, 2019 at 12:15 vote accept programming_amazing
Mar 27, 2019 at 5:59 comment added HelgeB @programming_amazing the status of a product is an eav attribute like other attributes you have in your query. Therefore you have to join the table of that attribute on the corresponding attribute id. That can be done either like you have done it with other attributes (join eav_attribute and join eav_attribute_int) or joining only eav_attribute_int and getting the attribute_id with the subquery. The result is the same and the above query should give you the results you need.
Mar 27, 2019 at 0:37 comment added karpa I did it mainly to avoid the code to be complicated to read. Now it is easier to read, maintain and add additional attributes to select. Maybe someone with better knowledge of MySQL can provide a better or faster alternative
Mar 27, 2019 at 0:31 comment added programming_amazing Thank you for replying! Could you please explain me why did you use a subquery?
Mar 27, 2019 at 0:24 history answered karpa CC BY-SA 4.0