Hi experts,
I'm desperately trying to get a result of a data query to my template.
I have a product object and an accessories table.
I want to show all products which are an accessory of a given product.
Here is my code:
$Accessories = ProductAccessory::get()->filter(array("ProductSKU" => $strSKU));
$aryReturn = array();
foreach($Accessories as $AccessoryItem) {
$aryReturn[] = Product::get()->filter(array("SKU" => $AccessoryItem->AccessorySKU))->First();
}
How can I get this array into a template? (the array is populated correctly, so thats not my problem)
I did try:
$data = array("Accessories" => $aryReturn);
$template = new SSViewer('ProductAccessoriesTable');
return $template->process(new ArrayData($data));
with ProductAccessoriesTable.ss
<% loop $Accessories %>
<tr>
<td>$Pos</td>
<td>$SKU</td>
<td>$ProductName</td>
</tr>
<% end_loop %>
But this doesn't work :-(
What can I do?
TIA Stephan