Jump to content

Display multiple attribute values as comma seperated


Recommended Posts

Hello dear friends,

In Prestashop 1.7, i need to display for every product all attribute values assigned, as comma seperated in a single line of a php file.

The following code calls the values and it works as a simple sql query as it appears the correct values

$sizes = Db::getInstance()->getRow('SELECT GROUP_CONCAT(name) FROM `ps_attribute_lang` fvl inner join ps_product_attribute_combination fp on fp.id_attribute = fvl.id_attribute inner join ps_product_attribute fl on fl.id_product_attribute = fp.id_product_attribute where fvl.id_lang = 6 and fl.id_product = "'.$product['id_product'].'" GROUP by fvl.id_lang');

The following line calls the previous variable but in my php file, this specific line comes empty

print $sizes["name"];

So, where is my bug? Thanks in advance!

 

P.S. The following line was looking for product features and were placed above the $sizes variable, and was working properly.

$sizes = Db::getInstance()->getRow('SELECT DISTINCT value FROM `ps_feature_value_lang` fvl inner join ps_feature_product fp on fp.id_feature_value = fvl.id_feature_value inner join ps_feature_lang fl on fl.id_feature = fp.id_feature where fl.id_lang = 6 and fp.id_product = "'.$product['id_product'].'"');

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...