Get attribute text from get_available_variations
-
Hi,
I have created a XML feed plugin, which is working fine.
One issue I have noticied, that when accessing the attributes for a variable product not the text form is presented in the array but the slug.
So ?okoláda => cokolada, banán => banan. I need the version (?okoláda, banán).Is there a way to get the text form? Or I have to create a replace array. I dont want to do that because we have 250 attributes, but if it is needed… :).
Part of my code:
$variations = $product->get_available_variations(); foreach ($variations as $var_id){ $productname = $dom->createElement("PRODUCTNAME"); $producta->appendChild($productname); if (!empty($var_id['attributes']['attribute_pa_prichut'])){ $cdata = $dom->createCDATASection($loop->post->post_title.' '.$var_id['attributes']['attribute_pa_prichut']); } elseif (!empty($var_id['attributes']['attribute_pa_velkost'])) { $cdata = $dom->createCDATASection($loop->post->post_title.' '.strtoupper($var_id['attributes']['attribute_pa_velkost'])); } elseif (!empty($var_id['attributes']['attribute_pa_farba'])) { $cdata = $dom->createCDATASection($loop->post->post_title.' '.$var_id['attributes']['attribute_pa_farba']); } else { $cdata = $dom->createCDATASection($loop->post->post_title); } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get attribute text from get_available_variations’ is closed to new replies.