Sylius: Creating cart via REST API takes long time

Created on 5 Oct 2017  路  4Comments  路  Source: Sylius/Sylius

| Q | A
| ---------------- | -----
| Bug report? | yes
| Feature request? | no
| BC Break report? | no
| RFC? | no
| Sylius version | 1.0.0

It occurs when you have a lot of customers in your database.

The proble is due that the Sylius\Bundle\AdminApiBundle\Form\Type\OrderType uses for customer the Sylius\Bundle\CustomerBundle\Form\Type\CustomerChoiceType type and therefore it loads all customers leading to out of memory problem.

To clarify I'm speaking form the API call explained in the docs http://docs.sylius.org/en/latest/api/carts.html#creating-a-cart

curl http://demo.sylius.org/api/v1/carts/ \
    -H "Authorization: Bearer SampleToken" \
    -H "Content-Type: application/json" \
    -X POST \
    --data '
        {
            "customer": "[email protected]",
            "channel": "US_WEB",
            "localeCode": "en_US"
        }
Potential Bug

Most helpful comment

Thanks, I'll try a pull request

All 4 comments

Fix: The ChoiceType should be replaced with a transformer form type (from e-mail to Customer or ResourceToIdentifierTransformer).

Thanks, I'll try a pull request

we experienced a lot of headaches with customers on Sylius 0.19 because of missing indexes on the right columns.

missing indexes + output walkers almost made our website crash due to high load. might wanna check the slow query log of MySQL.

I guess that this issue can be closed after https://github.com/Sylius/Sylius/pull/8778 was merged

Was this page helpful?
0 / 5 - 0 ratings