Can’t update an order customFields in my subscriber listening to OrderEvents::ORDER_WRITTEN_EVENT
OrderEvents::ORDER_WRITTEN_EVENT => 'onOrderSaved',
here is my callback function onOrderSaved
public function onOrderSaved(EntityWrittenEvent $event)
{
$session = new Session();
$shop = $session->get('pickup-location');
$results = $event->getWriteResults();
$payloads = [];
foreach($results as $result){
$payload = $result->getPayload();
$payload["customFields"] = ["shop" => $shop];
$payloads[] = $payload;
}
$this->orderRepository->upsert([$payload], Context::createDefaultContext());
dd("done");
}
if i will dump the variable
$payloads
it’s all okay, no error happened. but when i try to update the order by using the following line
$this->orderRepository->upsert($payloads, Context::createDefaultContext());
or
$this->orderRepository->update($payloads, Context::createDefaultContext());
it will give me an error maximum_execution_time of 0 excited.
I can’t find where it is going into an infinite loop or something like that because the $event-\>getWriteResults()
only got 1 occurence.
so something is going wrong in the core repository orders in shopware 6.
btw here is my service in services.xml
and my constructor
/**
* @var SystemConfigService
*/
private $systemConfigService;
/**
* @var EntityRepositoryInterface
*/
private $krsShopsRepository;
/**
* @var EntityRepositoryInterface
*/
private $orderRepository;
/**
* @var EntityRepositoryInterface
*/
private $orderToShopsRepository;
public function __construct(
SystemConfigService $systemConfigService,
EntityRepositoryInterface $krsShopsRepository,
EntityRepositoryInterface $orderRepository
)
{
$this->systemConfigService = $systemConfigService;
$this->krsShopsRepository = $krsShopsRepository;
$this->orderRepository = $orderRepository;
}
and here is a screenshot of the error, replace the 60 with 0 in the error below, thats my error
I personally dont think that editing my php.ini and set max_execution_time works, because i need to wait almost 200 seconds before error pop up.
Way too long for just editing a order right?
I can’t find what to do anymore. Is there al possible workaround? A good one…
or is it a bug in Shopware and do i need to wait for the fix?