Skip to content
For AI agents: the complete documentation index is available at llms.txt; this page is also available as Markdown at index.md.

Install shopping list

Install framework

Run the following command to install the package:

1
composer require ibexa/shopping-list

The associated Symfony Flex recipe configures the bundle and its routes.

Check that the following line has been added by the recipe to config/bundles.php file's array:

1
2
3
4
return [
    // ...
    Ibexa\Bundle\ShoppingList\IbexaShoppingListBundle::class => ['all' => true],
];

And that you have a config/routes/ibexa_shopping_list.yaml file configuring the following routes:

1
2
3
4
5
6
ibexa.shopping_list:
    resource: '@IbexaShoppingListBundle/Resources/config/routing.php'

ibexa.rest.shopping_list:
    resource: '@IbexaShoppingListBundle/Resources/config/routing_rest.php'
    prefix: '%ibexa.rest.path_prefix%'

Modify database schema

Ibexa Doctrine migrations manage the database schema for this package.

  • To see a list of known migrations, and find out which ones are pending for the whole project, run:

    1
    php bin/console ibexa:doctrine:migrations:versions
    
  • To preview the changes before you apply them, use --dry-run with --write-sql:

    1
    php bin/console ibexa:doctrine:migrations:migrate --dry-run --write-sql=var/migration-preview.sql
    

Preview only

This generates an SQL file that is only intended for review. More recent migrations can be unaware of changes made by earlier migrations in the same run, so the file may be incomplete. Do not run the SQL file against your database.

Always apply changes by running the command without the --dry-run flag.

  • To apply pending migrations:

    1
    php bin/console ibexa:doctrine:migrations:migrate
    

    This command does more than create the Shopping list tables - it applies all pending migrations for the project.

    The ibexa:doctrine:migrations:migrate command creates the required data structures, but doesn't add any data to the database.

Apply migrations one by one

Instead of applying all pending migrations at once, you can go through them one at a time. To preview only the next pending migration, run:

1
php bin/console ibexa:doctrine:migrations:migrate next --dry-run

Then, to apply it, run the same command without the --dry-run option:

1
php bin/console ibexa:doctrine:migrations:migrate next

Repeat these steps until no pending migrations remain. To check which migrations are still pending, run php bin/console ibexa:doctrine:migrations:status.

Initially, users don't have any shopping lists, not even the default “My Wishlist” list. The default shopping list is created automatically when the user triggers the "Add to wishlist" action for the first time.

Configure

By default, the maximum shopping list count per user is 10 and the maximum entries per list is 100. When listing their shopping lists, the user see 25 lists per page (and as it's over the shopping list count, there is always one page of shopping lists in this default scenario).

You can override the following parameters to change their values:

1
2
3
4
parameters:
    ibexa.site_access.config.default.shopping_list.limits.max_lists_per_user: 10
    ibexa.site_access.config.default.shopping_list.limits.max_entries_per_list: 100
    ibexa.site_access.config.default.shopping_list.pagination.list_per_page_limit: 25

Max lists per user and default shopping list

The customer can always create the default shopping list if it doesn't exist yet, even if they have already reached the limit defined by max_lists_per_user. So, for 10 as the default limit, the user may have 11 lists if the user created 10 custom lists before creating the default one. If you want to restrict users to only the default shopping list, you can set max_lists_per_user to 0.

Shopping list user role

To allow customers to use the shopping list feature, create a new role and assign it to registered customer groups. To restrict authenticated users access to only their own lists, you must grant the four functions from the Shopping List module with the limitation 'Shopping List Owner: Self'. Otherwise, they will be able to interact with all shopping lists existing in the system. Anonymous users can't have shopping lists as they're internally sharing the same account.

To create such role, you can use a migration file, for example, with the following content:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-   type: role
    mode: create
    metadata:
        identifier: Shopping List User
    policies:
        -   module: shopping_list
            function: create
            limitations:
                -   identifier: ShoppingListOwner
                    values: [self]
        -   module: shopping_list
            function: view
            limitations:
                -   identifier: ShoppingListOwner
                    values: [self]
        -   module: shopping_list
            function: edit
            limitations:
                -   identifier: ShoppingListOwner
                    values: [self]
        -   module: shopping_list
            function: delete
            limitations:
                -   identifier: ShoppingListOwner
                    values: [self]

On a clean install, you can, for example, assign this "Shopping List User" role to the "Customers" user group.

After placing the migration content in src/Migrations/Ibexa/migrations/shopping_list_user.yaml, you can import and execute it with:

1
php bin/console ibexa:doctrine:migrations:migrate --file=shopping_list_user.yaml --siteaccess=admin