x97wehner Posted September 27, 2023 Posted September 27, 2023 Hello, I'm using the datakick module and trying to figure out how to parse out the color name from my combinations and add it to a google data feed. I have the structure working for everything else except I cannot establish how to pull just the color from a combination that has multiple attributes into the g:color data field. Anyone know this? @datakick
datakick Posted September 27, 2023 Posted September 27, 2023 There is combinationAttributeValue function: https://www.getdatakick.com/function/combination-attribute-value/
x97wehner Posted September 27, 2023 Author Posted September 27, 2023 1 hour ago, datakick said: There is combinationAttributeValue function: https://www.getdatakick.com/function/combination-attribute-value/ I tried this and doesn't seem to work given the combinations have multiple attributes. If returns null in all scenarios that I tried. I ended up getting it to work like this. <g:color> if(attributeValue.attributeType == 'color', attributeValue.value, trim(toString(null))) </g:color> I'm sure there is a better way, but this is the only way I could make this one work. If there is, please show. Now I'm struggling to figure out how to grab just the size attribute from a combination with many attributes. And insight @datakick?
datakick Posted September 27, 2023 Posted September 27, 2023 30 minutes ago, x97wehner said: If returns null in all scenarios that I tried. Congrats, you have discovered a bug 🙂 This will be fixed in next release. Meanwhile, you can edit file modules/datakick/engine/prestashop/functions/combination-attribute-value.php and change lines 97 and 88 from AND comb.id_product_attribute = ' . (int)$combinationId . ' AND a.id_attribute_group = ' . (int)$attribute . ' to AND comb.id_product_attribute = ' . $combinationId . ' AND a.id_attribute_group = ' . $attribute . ' With the fix in place, you can extract any attribute value, if you know attribute group id. For example, if I have these attributes groups: I can create list of combination, and use combination id + constant 3 to extract color from combination: combinationAttributeValue(combinations.id, 3)
x97wehner Posted September 27, 2023 Author Posted September 27, 2023 23 minutes ago, datakick said: Congrats, you have discovered a bug 🙂 This will be fixed in next release. Meanwhile, you can edit file modules/datakick/engine/prestashop/functions/combination-attribute-value.php and change lines 97 and 88 from AND comb.id_product_attribute = ' . (int)$combinationId . ' AND a.id_attribute_group = ' . (int)$attribute . ' to AND comb.id_product_attribute = ' . $combinationId . ' AND a.id_attribute_group = ' . $attribute . ' With the fix in place, you can extract any attribute value, if you know attribute group id. For example, if I have these attributes groups: I can create list of combination, and use combination id + constant 3 to extract color from combination: combinationAttributeValue(combinations.id, 3) Awesome. I appreciate the quick follow-up and fix.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now