Skip to content

POST V1/inventory/source-selection-algorithm-result throws exception #1524

Closed
@keharper

Description

@keharper

When I call the http:///rest/us/V1/inventory/source-selection-algorithm-result with the following payload, Magento throws the exception provided at the bottom of this description.

{
    "inventoryRequest": {
        "stock_id": 2,
        "items": [{
            "sku": "sp1",
            "qty": 20
        },
        {
            "sku": "sp2",
            "qty": 60
        }]
    },
    "algorithmCode": "priority"
}

All store codes, stock_id, sku, and qty values are valid. I successfully created an invoice, but when I try to find the SSA with this call, the call fails.

Preconditions

  1. Latest 2.3-develop branch

Steps to reproduce

I think the easiest way to reproduce is to use the sample data and supply this payload while specifying all instead of us in the endpoint route.

{
    "inventoryRequest": {
        "stock_id": 1,
        "items": [{
            "sku": "testSimpleProduct",
            "qty": 20
        },
        {
            "sku": "testSimpleProduct2",
            "qty": 60
        }]
    },
    "algorithmCode": "priority"
}

Expected result

  1. A valid response

Actual result

<br />
<font size='1'>
    <table class='xdebug-error xe-uncaught-exception' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
        <tr>
            <th align='left' bgcolor='#f57900' colspan="5">
                <span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Uncaught Error: Call to a member function getSku() on array in /Users/keharper/msi/vagrant-magento/magento2ce/app/code/Magento/InventorySourceSelection/Model/Algorithms/PriorityBasedAlgorithm.php on line
                <i>84</i>
            </th>
        </tr>
        <tr>
            <th align='left' bgcolor='#f57900' colspan="5">
                <span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Error: Call to a member function getSku() on array in /Users/keharper/msi/vagrant-magento/magento2ce/app/code/Magento/InventorySourceSelection/Model/Algorithms/PriorityBasedAlgorithm.php on line
                <i>84</i>
            </th>
        </tr>
        <tr>
            <th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th>
        </tr>
        <tr>
            <th align='center' bgcolor='#eeeeec'>#</th>
            <th align='left' bgcolor='#eeeeec'>Time</th>
            <th align='left' bgcolor='#eeeeec'>Memory</th>
            <th align='left' bgcolor='#eeeeec'>Function</th>
            <th align='left' bgcolor='#eeeeec'>Location</th>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>1</td>
            <td bgcolor='#eeeeec' align='center'>0.0000</td>
            <td bgcolor='#eeeeec' align='right'>362568</td>
            <td bgcolor='#eeeeec'>{main}(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/index.php' bgcolor='#eeeeec'>.../index.php
                <b>:</b>0
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>2</td>
            <td bgcolor='#eeeeec' align='center'>0.0640</td>
            <td bgcolor='#eeeeec' align='right'>4489792</td>
            <td bgcolor='#eeeeec'>Magento\Framework\App\Bootstrap->run(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/index.php' bgcolor='#eeeeec'>.../index.php
                <b>:</b>39
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>3</td>
            <td bgcolor='#eeeeec' align='center'>0.0674</td>
            <td bgcolor='#eeeeec' align='right'>4866528</td>
            <td bgcolor='#eeeeec'>Magento\Framework\App\Http\Interceptor->launch(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/lib/internal/Magento/Framework/App/Bootstrap.php' bgcolor='#eeeeec'>.../Bootstrap.php
                <b>:</b>256
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>4</td>
            <td bgcolor='#eeeeec' align='center'>0.0679</td>
            <td bgcolor='#eeeeec' align='right'>4868808</td>
            <td bgcolor='#eeeeec'>Magento\Framework\App\Http\Interceptor->launch(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/generated/code/Magento/Framework/App/Http/Interceptor.php' bgcolor='#eeeeec'>.../Interceptor.php
                <b>:</b>24
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>5</td>
            <td bgcolor='#eeeeec' align='center'>0.2178</td>
            <td bgcolor='#eeeeec' align='right'>9784432</td>
            <td bgcolor='#eeeeec'>Magento\Webapi\Controller\Rest\Interceptor->dispatch(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/lib/internal/Magento/Framework/App/Http.php' bgcolor='#eeeeec'>.../Http.php
                <b>:</b>135
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>6</td>
            <td bgcolor='#eeeeec' align='center'>0.2187</td>
            <td bgcolor='#eeeeec' align='right'>9856584</td>
            <td bgcolor='#eeeeec'>Magento\Webapi\Controller\Rest\Interceptor->___callPlugins(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php' bgcolor='#eeeeec'>.../Interceptor.php
                <b>:</b>26
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>7</td>
            <td bgcolor='#eeeeec' align='center'>0.2187</td>
            <td bgcolor='#eeeeec' align='right'>9857328</td>
            <td bgcolor='#eeeeec'>Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/lib/internal/Magento/Framework/Interception/Interceptor.php' bgcolor='#eeeeec'>.../Interceptor.php
                <b>:</b>153
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>8</td>
            <td bgcolor='#eeeeec' align='center'>0.2277</td>
            <td bgcolor='#eeeeec' align='right'>9925600</td>
            <td bgcolor='#eeeeec'>Magento\Webapi\Controller\Rest\Interceptor->___callParent(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/lib/internal/Magento/Framework/Interception/Interceptor.php' bgcolor='#eeeeec'>.../Interceptor.php
                <b>:</b>138
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>9</td>
            <td bgcolor='#eeeeec' align='center'>0.2277</td>
            <td bgcolor='#eeeeec' align='right'>9925600</td>
            <td bgcolor='#eeeeec'>Magento\Webapi\Controller\Rest\Interceptor->dispatch(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/lib/internal/Magento/Framework/Interception/Interceptor.php' bgcolor='#eeeeec'>.../Interceptor.php
                <b>:</b>58
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>10</td>
            <td bgcolor='#eeeeec' align='center'>0.2357</td>
            <td bgcolor='#eeeeec' align='right'>10321800</td>
            <td bgcolor='#eeeeec'>Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/app/code/Magento/Webapi/Controller/Rest.php' bgcolor='#eeeeec'>.../Rest.php
                <b>:</b>188
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>11</td>
            <td bgcolor='#eeeeec' align='center'>0.2870</td>
            <td bgcolor='#eeeeec' align='right'>12729200</td>
            <td bgcolor='#eeeeec'>
                <a href='http://www.php.net/function.call-user-func-array:{/Users/keharper/msi/vagrant-magento/magento2ce/app/code/Magento/Webapi/Controller/Rest/SynchronousRequestProcessor.php:95}' target='_new'>call_user_func_array:{/Users/keharper/msi/vagrant-magento/magento2ce/app/code/Magento/Webapi/Controller/Rest/SynchronousRequestProcessor.php:95}</a>
(  )
            </td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/app/code/Magento/Webapi/Controller/Rest/SynchronousRequestProcessor.php' bgcolor='#eeeeec'>.../SynchronousRequestProcessor.php
                <b>:</b>95
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>12</td>
            <td bgcolor='#eeeeec' align='center'>0.2870</td>
            <td bgcolor='#eeeeec' align='right'>12729608</td>
            <td bgcolor='#eeeeec'>Magento\InventorySourceSelection\Model\SourceSelectionService->execute(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/app/code/Magento/Webapi/Controller/Rest/SynchronousRequestProcessor.php' bgcolor='#eeeeec'>.../SynchronousRequestProcessor.php
                <b>:</b>95
            </td>
        </tr>
        <tr>
            <td bgcolor='#eeeeec' align='center'>13</td>
            <td bgcolor='#eeeeec' align='center'>0.3087</td>
            <td bgcolor='#eeeeec' align='right'>12893352</td>
            <td bgcolor='#eeeeec'>Magento\InventorySourceSelection\Model\Algorithms\PriorityBasedAlgorithm->execute(  )</td>
            <td title='/Users/keharper/msi/vagrant-magento/magento2ce/app/code/Magento/InventorySourceSelection/Model/SourceSelectionService.php' bgcolor='#eeeeec'>.../SourceSelectionService.php
                <b>:</b>62
            </td>
        </tr>
    </table>
</font>
{"messages":{"error":[{"code":500,"message":"Fatal Error: 'Uncaught Error: Call to a member function getSku() on array in \/Users\/keharper\/msi\/vagrant-magento\/magento2ce\/app\/code\/Magento\/InventorySourceSelection\/Model\/Algorithms\/PriorityBasedAlgorithm.php:84\nStack trace:\n#0 \/Users\/keharper\/msi\/vagrant-magento\/magento2ce\/app\/code\/Magento\/InventorySourceSelection\/Model\/SourceSelectionService.php(62): Magento\\InventorySourceSelection\\Model\\Algorithms\\PriorityBasedAlgorithm->execute(Object(Magento\\InventorySourceSelection\\Model\\Request\\InventoryRequest))\n#1 [internal function]: Magento\\InventorySourceSelection\\Model\\SourceSelectionService->execute(Object(Magento\\InventorySourceSelection\\Model\\Request\\InventoryRequest), 'priority')\n#2 \/Users\/keharper\/msi\/vagrant-magento\/magento2ce\/app\/code\/Magento\/Webapi\/Controller\/Rest\/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)\n#3 \/Users\/keharper\/msi\/vagrant-magento\/magento2ce\/app\/code\/Magento\/Webapi\/Controller\/Rest.php(188): Magento\\Webapi\\Controller\\Rest\\SynchronousRequestProcessor->process(Object(Magento\\Fr' in '\/Users\/keharper\/msi\/vagrant-magento\/magento2ce\/app\/code\/Magento\/InventorySourceSelection\/Model\/Algorithms\/PriorityBasedAlgorithm.php' on line 84","trace":"Trace is not available."}]}}

Metadata

Metadata

Assignees

Labels

WEB APIMSI web API failures and fixes

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions