Ich glaube so könnte es gehen. Es wird praktisch ein Hilfs-Array „$sOrdersAttribute“ erzeugt welche alle Attribute zur jeweiligen Bestellnummer enthält. Im Template „order_item_details.tpl“ wird nur noch an der gewünschten Position der Inhalt vom Hilfs-Array ausgelesen - also so „{$sOrdersAttribute[$offerPosition.ordernumber][‚attribute1‘]}“ für Spalte „attribute1“.
Das ganze funktioniert jedenfalls unter Shopware 5.7.6
<?php
namespace testOrder;
use Shopware\Components\Plugin;
use Shopware\Components\Plugin\Context\InstallContext;
use Shopware\Components\Plugin\Context\UpdateContext;
use Shopware\Components\Plugin\Context\ActivateContext;
use Shopware\Components\Plugin\Context\DeactivateContext;
use Shopware\Components\Plugin\Context\UninstallContext;
class testOrder extends Plugin {
/**/
public function install(InstallContext $context) {
}
/**/
public function activate(ActivateContext $context) {
$context->scheduleClearCache(ActivateContext::CACHE_LIST_ALL);
}
/**/
public function update(UpdateContext $context) {
$context->scheduleClearCache(UpdateContext::CACHE_LIST_ALL);
}
/**/
public function deactivate(DeactivateContext $context) {
$context->scheduleClearCache(DeactivateContext::CACHE_LIST_ALL);
}
/**/
public function uninstall(UninstallContext $context) {
if ($context->getPlugin()->getActive()) { $context->scheduleClearCache(UninstallContext::CACHE_LIST_ALL); }
}
/**/
public static function getSubscribedEvents() {
$events = Array(
'Enlight_Controller_Action_Frontend_Account_Orders' => 'Frontend_Account_Orders',
);
return $events;
}
/////////////////////////////////////////////////////////
/*
Im Template die Attribute dann so ausgeben:
{$sOrdersAttribute[Bestellnummer][Name Attributspalte in Datenbank]}
{$sOrdersAttribute[$offerPosition.ordernumber]['attribute1']}
*/
public function Frontend_Account_Orders(\Enlight_Event_EventArgs $arguments) {
$controller = $arguments->getSubject();
$request = $controller->Request();
$view = $controller->View();
$admin = Shopware()->Modules()->Admin();
$destinationPage = (int)$request->sPage;
$orderData = $admin->sGetOpenOrderData($destinationPage);
$sOrdersAttribute = [];
foreach ( $orderData['orderData'] as $val ) {
$sOrdersAttribute[ $val['ordernumber'] ] = $this->GetOrdersAttribute($val['id']);
}
$view->assign('sOrdersAttribute', $sOrdersAttribute );
}
/**/
public function GetOrdersAttribute( $orderID ) {
$query = "SELECT * FROM s_order_attributes WHERE orderID = ? ";
return Shopware()->Db()->fetchRow($query, [ $orderID ] );
}
}
?>