Quantcast
Channel: Programming - Shopware Community Forum
Viewing all articles
Browse latest Browse all 118

REST-API: Status ID einer Bestellung ändern

$
0
0
Ich versuche, den Bestellstatus einer Bestellung über die REST-Api zu ändern.

Mit folgendem Snippet müsste es gehen, stattdessen fliegt ne Exception:
$orderResource = \Shopware\Components\Api\Manager::getResource('Order');
$orderResource->update(65, array(
    'orderStatusId' => 1,
));
Das Resultat:
The identifier id is missing for a query of Shopware\Models\User\User in Doctrine/ORM/ORMException.php on line 150
Stack trace:

#0 Doctrine/ORM/EntityRepository.php(116): Doctrine\ORM\ORMException::missingIdentifierField('Shopware\Models...', 'id')
#1 Shopware/Components/Model/ModelRepository.php(164): Doctrine\ORM\EntityRepository->find(NULL, 0, NULL)
#2 Doctrine/ORM/EntityManager.php(371): Shopware\Components\Model\ModelRepository->find(NULL, 0, NULL)
#3 Shopware/Models/Order/Order.php(1074): Doctrine\ORM\EntityManager->find('Shopware\Models...', NULL)
#4 Doctrine/ORM/Mapping/ClassMetadataInfo.php(1880): Shopware\Models\Order\Order->beforeUpdate()
#5 Doctrine/ORM/UnitOfWork.php(940): Doctrine\ORM\Mapping\ClassMetadataInfo->invokeLifecycleCallbacks('postUpdate', Object(Shopware\Models\Order\Order))
#6 Doctrine/ORM/UnitOfWork.php(310): Doctrine\ORM\UnitOfWork->executeUpdates(Object(Doctrine\ORM\Mapping\ClassMetadata))
#7 Doctrine/ORM/EntityManager.php(355): Doctrine\ORM\UnitOfWork->commit(NULL)
#8 Shopware/Components/Api/Resource/Resource.php(196): Doctrine\ORM\EntityManager->flush(NULL)
#9 Shopware/Components/Api/Resource/Order.php(185): Shopware\Components\Api\Resource\Resource->flush()
#10 Shopware\Components\Api\Resource\Order->update(65, Array)
Wenn man stattdessen das Status-Objekt direkt reinschreibt:
$orderResource = \Shopware\Components\Api\Manager::getResource('Order');
$state = Shopware()->Models()->getRepository('Shopware\Models\Order\Status')->findOneBy(array(
    'id'    => 1,
    'group' => 'state',
));
$orderResource->update(65, array(
    'orderStatus' => $state,
));
... dann scheint zwar alles zu funktionieren (keine Exception, das order-object wird returned), allerdings wurde der Status nicht aktualisiert:
...
  ["orderStatus"] => &array(5) {
    ["id"] => int(0)
    ["description"] => string(5) "Offen"
    ["position"] => int(1)
    ["group"] => string(5) "state"
    ["sendMail"] => int(1)
  }
...

getestet mit Shopware 4.0.3

Viewing all articles
Browse latest Browse all 118

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>