Quantcast
Channel: Programmierung - Shopware Community Forum
Viewing all articles
Browse latest Browse all 2871

Exception beim Anlegen eines Artikel über Plugin (Resources) - Problem mit Prices

$
0
0

Guten Morgen,

Ich entwickle eine Schnittstelle und lege dazu die Artikel über die API Funktionen von Shopware an:

$resource = \Shopware\Components\Api\Manager::getResource('article');

$articleData = array(
    'name' => $line[2],
    'taxId' => $taxId,
    'mainDetail' => array(
        'number' => $line[0],
        'inStock' => $line[15],
        'prices' => array(
            array(
                'customerGroupKey' =>'EK',
                'from' => 1,
                'to' => 'beliebig',
                'price' => $line[10],
                'basePrice' => 0,
                'percent' => 0
            )
        ),
    ),
    'categories' => array(
        array(
            'id' => 3
        )
    ),
    'supplier' => 'TBD',
    'description' => 'description',
    'descriptionLong' => 'descriptionLong',
    'active' => true,
);

$article = $resource->create($articleData);

Das alles funktioniert wunderbar, solange der "prices" node nicht enthalten ist. Sobald ich die "prices" wie oben zu sehen definieren, gibt es beim Ausführen nachfolgende Exception. Es handelt sich dabei nur um eine Notice aber ganz offensichtlich hat es hier ein Problem mit einem Array Index. Artikel und Preise werden dennoch angelegt.

PHP Notice:  Undefined index: key in /data/www/www.dev/engine/Library/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php on line 671
PHP Stack trace:
PHP   1. {main}() /data/www/www.dev/bin/console:0
PHP   2. Symfony\Component\Console\Application->run() /data/www/www.dev/bin/console:38
PHP   3. Shopware\Components\Console\Application->doRun() /data/www/www.dev/vendor/symfony/console/Application.php:123
PHP   4. Symfony\Component\Console\Application->doRun() /data/www/www.dev/engine/Shopware/Components/Console/Application.php:132
PHP   5. Symfony\Component\Console\Application->doRunCommand() /data/www/www.dev/vendor/symfony/console/Application.php:192
PHP   6. Symfony\Component\Console\Command\Command->run() /data/www/www.dev/vendor/symfony/console/Application.php:844
PHP   7. PhaIdxInterface\Commands\ImportCommand->execute() /data/www/www.dev/vendor/symfony/console/Command/Command.php:259
PHP   8. PhaIdxInterface\Lib\Articles->importArticles() /data/www/www.dev/custom/plugins/PhaIdxInterface/Commands/ImportCommand.php:79
PHP   9. Shopware\Components\Api\Resource\Article->create() /data/www/www.dev/custom/plugins/PhaIdxInterface/Lib/Articles.php:171
PHP  10. Shopware\Components\Api\Resource\Resource->flush() /data/www/www.dev/engine/Shopware/Components/Api/Resource/Article.php:541
PHP  11. Doctrine\ORM\EntityManager->flush() /data/www/www.dev/engine/Shopware/Components/Api/Resource/Resource.php:260
PHP  12. Doctrine\ORM\UnitOfWork->commit() /data/www/www.dev/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:356
PHP  13. Doctrine\ORM\UnitOfWork->executeInserts() /data/www/www.dev/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:378
PHP  14. Doctrine\ORM\Persisters\Entity\BasicEntityPersister->executeInserts() /data/www/www.dev/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:1018
PHP  15. Doctrine\ORM\Persisters\Entity\BasicEntityPersister->prepareInsertData() /data/www/www.dev/engine/Library/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:271
PHP  16. Doctrine\ORM\Persisters\Entity\BasicEntityPersister->prepareUpdateData() /data/www/www.dev/engine/Library/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:722

Habe ich hier vielleicht einen Fehler im Aufbau des Arrays?

Bin Euch für jeden Tipp dankbar,

Liebe Grüße,
Synonymous


Viewing all articles
Browse latest Browse all 2871

Trending Articles



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