sGetArticleById führt zu Internal Server Error (obwohl ID gültig)

Hallo liebe Community,

ich fange langsam an an meinem Verstand zu zweifeln :smiley:
Folgender Codeschnipsel:

 

$art = Shopware()->Modules()->Articles();

$articleId = $art->sGetArticleIdByOrderNumber(565030);
$article = $art->sGetArticleById($articleId);

print_r($article);
die();

Ich rufe diesen Code-Teil innerhalb eines Services auf, den ich geschrieben habe (zu Testzwecken habe ich eine Ordernumber, die existiert, fest hinterlegt).
Seltsamerweise funktioniert der Aufruf von sGetArticleIdByOrderNumber() reibungslos und ich bekomme die korrekte ID zurückgegeben. Sobald ich aber sGetArticleById() aufrufe bricht mir die Kiste mit einem 500er Internal Server Error weg.
Dasselbe passsiert, wenn ich eine ID hardcoded übergebe, die definitiv existiert.

Hat jemand eine Ahnung, was hier die Ursache sein kann?  Undecided

Liebe Grüße
bquarta

Aktiviere doch erst einmal die Ausgabe von Fehlermeldungen:
https://community.shopware.com/config.php-Tweaks_detail_1801.html
https://community.shopware.com/Fehlermeldungen-in-Shopware-debuggen_detail_1880.html

Viele Grüße

Hallo EikeWarneke,

es steht leider nunmal nichts wirklich brauchbares für mich in den Logs.
Der Apache-Error-Log sagt zu dem Aufruf:

[Sat Sep 15 17:09:37.394841 2018] [fcgid:error] [pid 61407] mod_fcgid: process /var/www/php-fcgi-scripts/web4/.php-fcgi-starter(29082) exit(communication error), get signal 11, possible coredump generated

Ansonsten findet sich kein Eintrag in den Logs im Shopware-Backend. Wenn ich allerdings eine ungültige ID (oder eben keine) in der Methode angebe, dann bekomme ich entsprechend auch etwas im Error-Log, nämlich:
No valid product number found

bzw. 

 

RuntimeException: No valid product number found in /engine/Shopware/Bundle/StoreFrontBundle/Service/Core/ProductNumberService.php:79 Stack trace:
#0 /engine/Shopware/Core/sArticles.php(1108): Shopware\Bundle\StoreFrontBundle\Service\Core\ProductNumberService->getMainProductNumberById(1)
#1 /custom/plugins/DekoDiscounts/Services/DiscountCalculator.php(33): sArticles->sGetArticleById(1)
#2 /custom/plugins/DekoDiscounts/Bundle/StoreFrontBundle/PriceCalculatorService.php(28): DekoDiscounts\Services\DiscountCalculator->calculateArticlePrice(32.77)
#3 /engine/Shopware/Bundle/StoreFrontBundle/Service/Core/PriceCalculationService.php(144): DekoDiscounts\Bundle\StoreFrontBundle\PriceCalculatorService->calculatePrice(32.77, Object(Shopware\Bundle\StoreFrontBundle\Struct\Tax), Object(Shopware\Bundle\StoreFrontBundle\Struct\ShopContext))
#4 /engine/Shopware/Bundle/StoreFrontBundle/Service/Core/PriceCalculationService.php(63): Shopware\Bundle\StoreFrontBundle\Service\Core\PriceCalculationService->calculatePriceStruct(Object(Shopware\Bundle\StoreFrontBundle\Struct\Product\PriceRule), Object(Shopware\Bundle\StoreFrontBundle\Struct\Tax), Object(Shopware\Bundle\StoreFrontBundle\Struct\ShopContext))
#5 /engine/Shopware/Bundle/StoreFrontBundle/Service/Core/ListProductService.php(176): Shopware\Bundle\StoreFrontBundle\Service\Core\PriceCalculationService->calculateProduct(Object(Shopware\Bundle\StoreFrontBundle\Struct\ListProduct), Object(Shopware\Bundle\StoreFrontBundle\Struct\ShopContext))
#6 /engine/Shopware/Bundle/StoreFrontBundle/Service/Core/ProductService.php(146): Shopware\Bundle\StoreFrontBundle\Service\Core\ListProductService->getList(Array, Object(Shopware\Bundle\StoreFrontBundle\Struct\ShopContext))
#7 /engine/Shopware/Bundle/StoreFrontBundle/Service/Core/ProductService.php(136): Shopware\Bundle\StoreFrontBundle\Service\Core\ProductService->getList(Array, Object(Shopware\Bundle\StoreFrontBundle\Struct\ShopContext))
#8 /engine/Shopware/Core/sArticles.php(1126): Shopware\Bundle\StoreFrontBundle\Service\Core\ProductService->get('565030', Object(Shopware\Bundle\StoreFrontBundle\Struct\ShopContext))
#9 /custom/plugins/DekoThreesixtySlider/Subscriber/PluginSubscriber.php(41): sArticles->sGetArticleById('1407')
#10 /engine/Library/Enlight/Event/Handler/Default.php(91): DekoThreesixtySlider\Subscriber\PluginSubscriber->onAfterFrontendDetail(Object(Enlight_Controller_ActionEventArgs))
#11 /engine/Library/Enlight/Event/EventManager.php(220): Enlight_Event_Handler_Default->execute(Object(Enlight_Controller_ActionEventArgs))
#12 /engine/Library/Enlight/Controller/Action.php(225): Enlight_Event_EventManager->notify('Enlight_Control...', Object(Enlight_Controller_ActionEventArgs))
#13 /engine/Library/Enlight/Controller/Dispatcher/Default.php(549): Enlight_Controller_Action->dispatch('indexAction')
#14 /engine/Library/Enlight/Controller/Front.php(222): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))
#15 /engine/Shopware/Kernel.php(215): Enlight_Controller_Front->dispatch()
#16 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(486): Shopware\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /engine/Shopware/Components/HttpCache/AppCache.php(268): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)
#18 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(443): Shopware\Components\HttpCache\AppCache->forward(Object(Symfony\Component\HttpFoundation\Request), true)
#19 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(339): Symfony\Component\HttpKernel\HttpCache\HttpCache->fetch(Object(Symfony\Component\HttpFoundation\Request), true)
#20 /engine/Shopware/Components/HttpCache/AppCache.php(189): Symfony\Component\HttpKernel\HttpCache\HttpCache->lookup(Object(Symfony\Component\HttpFoundation\Request), true)
#21 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(205): Shopware\Components\HttpCache\AppCache->lookup(Object(Symfony\Component\HttpFoundation\Request), true)
#22 /engine/Shopware/Components/HttpCache/AppCache.php(116): Symfony\Component\HttpKernel\HttpCache\HttpCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/clients/client1/web4/web/shopware.php(122): Shopware\Components\HttpCache\AppCache->handle(Object(Symfony\Component\HttpFoundation\Request))
#24 {main}

Je nachdem was ich dort halt absichtlich falsch eingebe.

Liebe Grüße

Hi @bquarta‍,

die Meldung sagt im Prinzip nur das keine Artikelnummer zu der gelieferten Id existiert.

Hallo @karlharris‍,

ja, dieser Fehler kommt ja auch nur dann, wenn ich ihn mit einer falschen ID provoziere. Wenn ich stattdessen eine gültige ID angebe, bzw. über sGetArticleIdByOrderNumber([GÜLTIGE ARTIKELNUMMER]) eine Artikel-ID beziehe (wo ich ja eine entsprechende ID auch zurück bekomme, das funktioniert), dann kommt mir eben besagter Internal-Server-Error beim Versuch auf diese ID ein sGetArticleById() zu feuern.
In letzterem Fall schweigt sich der Log auch komplett aus. Genau das ist ja mein Problem :wink:

Liebe Grüße

Hi @bquarta‍,

moment, der Fehler bei dir kommt wenn du diese Zeile (mit existenter Id) aufrufst?:

$article = $art->sGetArticleById($articleId);

 

Hallo @karlharris‍,
ganz genau so ist es: Die oben genannten Fehler kommen nur bei falscher ID (das war ein Test, quasi als Antwort auf EikeWarnekes Kommentar).

Wenn ich es allerdings so aufrufe, wie du schreibst, dann bekomme ich einen Internal Server Error und keine Infos in den Logs dazu.

Alles was ich dann finde ist im Apache Error log folgendes:
[Sat Sep 15 17:09:37.394841 2018] [fcgid:error] [pid 61407] mod_fcgid: process /var/www/php-fcgi-scripts/web4/.php-fcgi-starter(29082) exit(communication error), get signal 11, possible coredump generated

Allerdings kann ich damit nicht wirklich viel anfangen.

Liebe Grüße

Anstatt Shopware()->Modules()->Articles() zu verwenden, hast Du schon mal den „shopware_storefront.product_service“ ausprobiert?

 

 

 

 

Scheint ein Context-Problem zu sein. Habe öfters auch solche nichtssagenden Fehler, dann wechsel ich meistens auf den Service (oder umgekehrt auf die Legacy Module)