SELECT
pf.feature_id,
pf.company_id,
pf.feature_type,
pf.parent_id,
pf.display_on_product,
pf.display_on_catalog,
pf.display_on_header,
cscart_product_features_descriptions.description,
cscart_product_features_descriptions.internal_name,
cscart_product_features_descriptions.lang_code,
cscart_product_features_descriptions.prefix,
cscart_product_features_descriptions.suffix,
pf.categories_path,
cscart_product_features_descriptions.full_description,
pf.status,
pf.comparison,
pf.position,
pf.purpose,
pf.feature_style,
pf.filter_style,
pf.feature_code,
pf.timestamp,
pf.updated_timestamp,
pf_groups.position AS group_position,
cscart_product_features_values.value,
cscart_product_features_values.variant_id,
cscart_product_features_values.value_int
FROM
cscart_product_features AS pf
LEFT JOIN cscart_product_features AS pf_groups ON pf.parent_id = pf_groups.feature_id
LEFT JOIN cscart_product_features_descriptions AS pf_groups_description ON pf_groups_description.feature_id = pf.parent_id
AND pf_groups_description.lang_code = 'en'
LEFT JOIN cscart_product_features_descriptions ON cscart_product_features_descriptions.feature_id = pf.feature_id
AND cscart_product_features_descriptions.lang_code = 'en'
INNER JOIN cscart_product_features_values ON cscart_product_features_values.feature_id = pf.feature_id
AND cscart_product_features_values.product_id = 291
AND cscart_product_features_values.lang_code = 'en'
INNER JOIN cscart_ult_objects_sharing ON (
cscart_ult_objects_sharing.share_object_id = pf.feature_id
AND cscart_ult_objects_sharing.share_company_id = 1
AND cscart_ult_objects_sharing.share_object_type = 'product_features'
)
WHERE
1 = 1
AND pf.feature_type != 'G'
AND pf.status IN ('A')
AND (
pf_groups.status IN ('A')
OR pf_groups.status IS NULL
)
AND pf.display_on_product = 'Y'
AND (
pf.categories_path = ''
OR ISNULL(pf.categories_path)
OR FIND_IN_SET(268, pf.categories_path)
OR FIND_IN_SET(273, pf.categories_path)
)
GROUP BY
pf.feature_id
ORDER BY
group_position asc,
pf_groups_description.description asc,
pf_groups.feature_id asc,
pf.position asc,
cscart_product_features_descriptions.description asc,
pf.feature_id asc