ethercreative / mailchimp-commerce

Mailchimp integration with Craft Commerce
Other
5 stars 11 forks source link

Syncing orders not working #14

Closed stenvdb closed 4 years ago

stenvdb commented 5 years ago

I am getting the following error as response to the failed queue task: Call to a member function getProduct() on null

All my products have synced successfully, but non of the carts seem to sync. I've also checked the store has an address filled in + orders have a return url. Anything else I can look into?

stenvdb commented 5 years ago

Any update on this?

Tam commented 5 years ago

@stenvdb Can you share the rest of the stacktrace from your log file?

stenvdb commented 5 years ago
2019-09-18 11:25:48 [-][1][-][info][craft\queue\QueueLogBehavior::beforeExec]  [27115] Syncing Orders to Mailchimp (attempt: 1) - Started
2019-09-18 11:25:48 [-][1][-][error][craft\queue\QueueLogBehavior::afterError]  [27115] Syncing Orders to Mailchimp (attempt: 1) - Error (time: 0.018s): Call to a member function getProduct() on null
2019-09-18 11:25:48 [-][1][-][error][Error] Error: Call to a member function getProduct() on null in /***/vendor/ether/mailchimp-commerce/src/services/OrdersService.php:405
Stack trace:
#0 /***/vendor/ether/mailchimp-commerce/src/services/OrdersService.php(272): ether\mc\services\OrdersService->_getProduct(NULL)
#1 /***/vendor/ether/mailchimp-commerce/src/services/OrdersService.php(56): ether\mc\services\OrdersService->_buildOrderData('291')
#2 /***/vendor/ether/mailchimp-commerce/src/jobs/SyncOrders.php(53): ether\mc\services\OrdersService->syncOrderById('291')
#3 /***/vendor/yiisoft/yii2-queue/src/Queue.php(214): ether\mc\jobs\SyncOrders->execute(Object(craft\queue\Queue))
#4 /***/vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue->handleMessage('27115', 'O:24:"ether\\mc\\...', '300', 1)
#5 /***/vendor/craftcms/cms/src/queue/Queue.php(96): yii\queue\cli\Queue->handleMessage('27115', 'O:24:"ether\\mc\\...', '300', 1)
#6 /***/vendor/craftcms/cms/src/controllers/QueueController.php(86): craft\queue\Queue->run()
#7 [internal function]: craft\controllers\QueueController->actionRun()
#8 /***/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /***/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#10 /***/vendor/craftcms/cms/src/web/Controller.php(187): yii\base\Controller->runAction('run', Array)
#11 /***/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('run', Array)
#12 /***/vendor/craftcms/cms/src/web/Application.php(299): yii\base\Module->runAction('queue/run', Array)
#13 /***/vendor/craftcms/cms/src/web/Application.php(566): craft\web\Application->runAction('queue/run', Array)
#14 /***/vendor/craftcms/cms/src/web/Application.php(278): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#15 /***/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#16 /***/www/index.php(23): yii\base\Application->run()
#17 {main}
stenvdb commented 5 years ago

I've fixed this myself in the pull request above. Please let me know if you find the time to merge this.

The issue was that line items might not have products related to them. Products can get deleted, but the line items of course not.