SELECT DISTINCT Finishs.* FROM ( SELECT PSA.id as 'finish_id', PSA.sort_order, PSAT.* FROM pri_store_attribute AS PSA INNER JOIN pri_store_attribute_text AS PSAT ON PSAT.id = PSA.id WHERE PSA.super_attribute_id = 2 AND PSAT.language_id = 'en' ) AS Finishs INNER JOIN ( SELECT DISTINCT PSP.*, PSPA.attribute_id as 'finish_id' FROM pri_store_product AS PSP INNER JOIN pri_store_product_attribute AS PSPA ON PSPA.product_id = PSP.id INNER JOIN pri_store_product_attribute AS PSPA2 ON PSPA2.product_id = PSP.id INNER JOIN pri_store_product_attribute AS PSPA3 ON PSPA3.product_id = PSP.id INNER JOIN pri_store_product_category AS PC1 ON PSP.id = PC1.product_id INNER JOIN pri_store_product_category AS PC2 ON PSP.id = PC2.product_id INNER JOIN pri_store_category_text AS PCT ON (PCT.id IN (36) AND PCT.language_id = 'en') WHERE PSP.status = 1 AND PC.category_id IN (36) AND PSPA.attribute_id IN ( SELECT I.finish_id FROM pri_store_product_index_2 AS I WHERE I.categories_urls LIKE CONCAT('%', PCT.url ,'%') ) ) as Products ON Products.finish_id = Finishs.id ORDER BY Finishs.sort_order ASC
Array