SELECT
v.feature_id,
v.value,
v.value_int,
v.variant_id,
f.feature_type,
fd.description,
fd.prefix,
fd.suffix,
vd.variant,
f.parent_id,
f.position,
gf.position as gposition,
f.display_on_header,
f.display_on_catalog,
f.display_on_product,
f.feature_code
FROM
cscart_product_features as f
LEFT JOIN cscart_product_features_values as v ON v.feature_id = f.feature_id
LEFT JOIN cscart_product_features_descriptions as fd ON fd.feature_id = v.feature_id
AND fd.lang_code = 'nl'
LEFT JOIN cscart_product_feature_variants fv ON fv.variant_id = v.variant_id
LEFT JOIN cscart_product_feature_variant_descriptions as vd ON vd.variant_id = fv.variant_id
AND vd.lang_code = 'nl'
LEFT JOIN cscart_product_features as gf ON gf.feature_id = f.parent_id
AND gf.feature_type = 'G'
INNER JOIN cscart_ult_objects_sharing ON (
cscart_ult_objects_sharing.share_object_id = f.feature_id
AND cscart_ult_objects_sharing.share_company_id = 1
AND cscart_ult_objects_sharing.share_object_type = 'product_features'
)
WHERE
f.status IN ('A')
AND v.product_id = 1202
AND f.display_on_header = 'Y'
AND (
f.categories_path = ''
OR FIND_IN_SET(302, f.categories_path)
OR FIND_IN_SET(434, f.categories_path)
)
AND IF(
f.parent_id,
(
SELECT
status
FROM
cscart_product_features as df
WHERE
df.feature_id = f.parent_id
),
'A'
) IN ('A')
AND (
v.variant_id != 0
OR (
f.feature_type != 'C'
AND v.value != ''
)
OR (f.feature_type = 'C')
OR v.value_int != ''
)
AND v.lang_code = 'nl'
ORDER BY
fd.description,
fv.position