0

我需要在 prestashop 1.5 中获得产品功能,但问题是我使用了一个修改,使我能够为每个产品的一个功能赋予多个价值

例子:

兼容的存储卡: - Carte Mémoire xD - Memory Stick - Memory Stick PRO - MultimediaCard (MMC) - Carte Secure Digital (SD)

我得到了这个查询:

Select fl.name, fvl.value, f.id_feature
From ps_feature_lang fl Left Join
  ps_feature_product fp On fl.id_feature = fp.id_feature And fp.id_product = 291
  Left Join
  ps_feature_value_lang fvl On fp.id_feature_value = fvl.id_feature_value And
    fvl.id_lang = 5 Left Join
  ps_feature f On f.id_feature = fl.id_feature
Where fl.id_feature In (Select ps__fc_categories_features.feature_id
  From ps__fc_categories_features)
Group By fl.name, fvl.value, f.id_feature, fl.id_feature
Order By f.position

但是如果给定产品的某个特征具有多个值,它将为该特征提供多个原始值 最好的查询是将每个具有多个值的特征的值连接起来

提前谢谢。

4

1 回答 1

0

您应该能够通过对查询进行小的调整来做到这一点。尝试这个:

Select fl.name, group_concat(fvl.value) as values, f.id_feature
From ps_feature_lang fl Left Join
     ps_feature_product fp
     On fl.id_feature = fp.id_feature And fp.id_product = 291 Left Join
     ps_feature_value_lang fvl
     On fp.id_feature_value = fvl.id_feature_value And fvl.id_lang = 5 Left Join
     ps_feature f
     On f.id_feature = fl.id_feature
Where fl.id_feature In (Select ps__fc_categories_features.feature_id
                        From ps__fc_categories_features
                       )
Group By fl.name, fl.id_feature
Order By f.position;

此查询从 中fvl.value删除并group by添加。我还删除了. 根据条件,这似乎是多余的。group_concat()selectf.id_featurejoin

于 2014-02-08T16:21:34.320 回答