SELECT
v.product_id,
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
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 = 'it'
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 = 'it'
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 in (435)
AND f.display_on_catalog = 'Y'
AND (
f.categories_path = ''
OR FIND_IN_SET(329, f.categories_path)
OR FIND_IN_SET(361, f.categories_path)
OR FIND_IN_SET(362, f.categories_path)
OR FIND_IN_SET(363, f.categories_path)
OR FIND_IN_SET(328, f.categories_path)
OR FIND_IN_SET(335, f.categories_path)
OR FIND_IN_SET(352, f.categories_path)
OR FIND_IN_SET(351, f.categories_path)
OR FIND_IN_SET(349, f.categories_path)
OR FIND_IN_SET(360, f.categories_path)
OR FIND_IN_SET(359, f.categories_path)
OR FIND_IN_SET(368, f.categories_path)
OR FIND_IN_SET(331, f.categories_path)
OR FIND_IN_SET(379, f.categories_path)
OR FIND_IN_SET(380, f.categories_path)
OR FIND_IN_SET(381, f.categories_path)
OR FIND_IN_SET(382, f.categories_path)
OR FIND_IN_SET(383, f.categories_path)
OR FIND_IN_SET(384, f.categories_path)
OR FIND_IN_SET(385, f.categories_path)
OR FIND_IN_SET(386, f.categories_path)
OR FIND_IN_SET(332, f.categories_path)
OR FIND_IN_SET(388, f.categories_path)
OR FIND_IN_SET(390, f.categories_path)
OR FIND_IN_SET(391, f.categories_path)
OR FIND_IN_SET(392, f.categories_path)
OR FIND_IN_SET(393, f.categories_path)
OR FIND_IN_SET(394, f.categories_path)
OR FIND_IN_SET(395, f.categories_path)
OR FIND_IN_SET(396, 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 = 'it'
ORDER BY
fd.description,
fv.position